擅长:python、mysql、java
<p>我刚刚在TensorFlow 2.4.0和NumPy 1.19.4上试过这个</p>
<pre class="lang-py prettyprint-override"><code>import numpy as np
import tensorflow as tf
bfloat16 = tf.bfloat16.as_numpy_dtype
np.array([1.0, 2.0, 3.0], dtype=bfloat16)
# array([bfloat16(1), bfloat16(2), bfloat16(3)], dtype=bfloat16)
</code></pre>