擅长:python、mysql、java
<p>对于<code>tf.math.reduce_std</code>和<code>tf.math.reduce_variance</code>输入张量必须是实数或复数类型。因此,只需将数据转换为float,然后再传递给以下函数:</p>
<pre><code>E = tf.constant(np.random.randint(low=0, high=100, size=50))
print(E)
# Add this line
E = tf.cast(E, dtype=tf.float32) # Convert to float 32
print(tf.math.reduce_std(E))
print(tf.math.reduce_variance(E))
</code></pre>