首页 > 解决方案 > 如何计算矩阵中变量的标准偏差

问题描述

我使用了 tensorflow 1.4,我想测试这个工具。像下面的例子:

将张量流导入为 tf

输入=[50,10]

O1 = layers.fully connected(input, 20, tf.sigmoid)

我猜代码没问题,但不太确定如何计算出矩阵中变量的标准偏差?非常感谢!

标签: tensorflowvariablesmatrix

解决方案


使用最新的 Tensorflow 版本 2.5,您可以使用计算标准偏差

import tensorflow as tf
x = tf.constant([[1., 2.], [3., 4.]])
tf.math.reduce_std(x)

输出

<tf.Tensor: shape(), dtype=float32, numpy=1.118034>

推荐阅读