tensorflow报错In[0] ndims must be >= 2: 1

import tensorflow as tf
import numpy as np
input1 = tf.placeholder(tf.float32)
input2 = tf.placeholder(tf.float32)

output = tf.matmul(input1, input2)

with tf.Session() as sess:
    print(sess.run(output, {
    
    input1:[1, 2], 
    input2:np.array([[1,2]]).T}))

出现报错,In[0] ndims must be >= 2: 1。发现原理是使用matmul时对象必须是秩>2的张量,这里两个张量相乘修改为multiply就好了

output = tf.multiply(input1, input2)

猜你喜欢

转载自blog.csdn.net/zhazha_hui/article/details/109142320
今日推荐