gpt4 book ai didi

tensorflow - 在 TensorflowJS 中计算标准偏差?

转载 作者:行者123 更新时间:2023-12-05 03:00:14 25 4
gpt4 key购买 nike

我正在编写我的第一个 TFJS 演示应用程序。我有一个训练有素的猫/狗二元分类器,我已经使用转换器进行了转换。我可以加载模型并传递来自 iphone 或 android 相机的图像进行分类。不幸的是,结果很糟糕。我的模型是使用 keras ImageDataGenerator 训练的,其中 samplewise_center 和 samplewise_std_normalization 都设置为 true。我现在很确定我需要在我的应用程序中进行相同的规范化。

我在完整的 API 中看到了 tf.math.reduce_mean() 和 reduce_std()。在 JS API 中,我看到 ts.mean() 但没有看到 ts.std()。我需要从头开始计算标准差吗?

最佳答案

在 js api 中还没有计算标准偏差的运算符。它可以从头开始计算,也可以使用 tf.moments 获取方差,然后使用平方根计算标准差。

const a = tf.tensor1d([1, 2, 3]);

tf.moments(a).variance.print()
tf.moments(a).variance.sqrt().print()

关于tensorflow - 在 TensorflowJS 中计算标准偏差?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56943451/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com