假设我有这样的嵌入层e
:
import tensorflow as tf
e = tf.keras.layers.Embedding(5,3)
如何打印其numpy值?
感谢@vald的回答。我认为e.embeddings
是更pythonic,也许有效。
import tensorflow as tf
e = tf.keras.layers.Embedding(5,3)
e.build(()) # You should build it before using.
print(e.embeddings)
>>>
<tf.Variable 'embeddings:0' shape=(5, 3) dtype=float32, numpy=
array([[ 0.02099125, 0.01865673, 0.03652272],
[ 0.02714007, -0.00316695, -0.00252246],
[-0.02411103, 0.02043924, -0.01297874],
[ 0.00766286, -0.03511617, 0.03460207],
[ 0.00256425, -0.03659264, -0.01796588]], dtype=float32)>
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句