在此行e.assign中,我遇到了TypeError:预期为浮点数,得到了数组
函数getE()返回一个与[50000,embedding_size]中指定形状相同的形状。
如何解决此错误?
import tensorflow.compat.v1 as tf
tf.reset_default_graph()
import numpy as np
session = tf.InteractiveSession()
embedding_size = 128
e = tf.Variable(tf.random_uniform([50000, embedding_size], 0, 1),validate_shape=False)
e.assign(getE())
但是,当我在spyder-console中运行相同的代码示例时,我没有遇到错误。
我应该尝试这段代码吗?:
import tensorflow.compat.v1 as tf
tf.reset_default_graph()
import numpy as np
session = tf.InteractiveSession()
embedding_size = 128
e = tf.Variable(tf.random_uniform([50000, embedding_size], 0, 1),validate_shape=False)
e = tf.assign(e, getE())
...或给我写信,如何解决此错误?