【问题标题】:Calculate Standard Deviation in TensorflowJS?计算TensorflowJS中的标准偏差?
【发布时间】:2019-07-10 21:08:33
【问题描述】:

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

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

【问题讨论】:

    标签: tensorflow tensorflow.js


    【解决方案1】:

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

    const a = tf.tensor1d([1, 2, 3]);
    
    tf.moments(a).variance.print()
    tf.moments(a).variance.sqrt().print()
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-09-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-11-04
      • 1970-01-01
      相关资源
      最近更新 更多