擅长:python、mysql、java
<p>要找到张量的方差,我们需要访问<code>tensorflow_probability</code></p>
<pre class="lang-py prettyprint-override"><code>import tensorflow_probability as tfp
tfp.stats.variance(E)
</code></pre>
<p>如果您使用下面的代码,请在传递到这些函数之前将数据转换为float,如下所示</p>
<pre class="lang-py prettyprint-override"><code>tf.math.reduce_variance(tf.cast(E, dtype=tf.float32))
</code></pre>
<p>要找到标准偏差,请在传递到这些函数之前将数据转换为float</p>
<pre class="lang-py prettyprint-override"><code>tfp.stats.stddev(tf.cast(E, dtype=tf.float32))
tf.math.reduce_std(tf.cast(E, dtype=tf.float32))
</code></pre>