我在尝试实现这几行代码时遇到了这个错误
形状的等级必须为2,但对于输入形状为100,100,?,15,100的'MatMul_46‘(op:'MatMul'),形状的等级为3。
Q = tf.placeholder(tf.float32, shape=(None, 15))
word_level = Embedding ( vocab_size , 100 , input_length=15)(Q)
#shape(?,15,100)
Wb = tf.Variable(tf.zeros([100, 100]))
C = tf.matmul( word_level ,Wb)我认为这个问题是因为三维和二维矩阵的秩不同,但我不知道如何修改这个问题。
发布于 2018-03-05 05:41:49
要修改张量以适合特定形状,可以使用tf.reshape,但要小心以有意义的方式重塑它。
reshape = tf.reshape(word_level, [-1, 100])
Wb = tf.Variable(tf.zeros([100, 100]))
C = tf.matmul(reshape ,Wb)https://stackoverflow.com/questions/49100680
复制相似问题