我是 Tensorflow 的初学者,如果我的问题很微不足道,我很抱歉,但我查看了文档和 Google,但找不到答案。 (我也为我的英语道歉)
我想做类似的事情
sess.run(train, {x:x_train, y:x_train}
其中 x_train 是一个大小为 3190 的数组,包含我的输入数据(维度为 60*4 的数组)
我的问题是,x 应该是:
x = tf.placeholder(tf.bool, [60,4])
或
x = tf.placeholder(tf.bool, [None,60,4])
?
第一个给出以下错误:
ValueError: Cannot feed value of shape (3190, 60, 4) for Tensor u'Placeholder:0', which has shape '(60, 4)'
如果我使用第二个,如果我想计算,我怎样才能用 0<=i<60 和 0<=j<4 达到 x[i][j]
tf.logical_and(x[i1][j1],x[i2][j2])
?
提前感谢您的回答。
最佳答案
一定要使用
x = tf.placeholder(tf.bool, [None,60,4])
供您逻辑和使用
x_flat = tf.reshape( x , [ -1 , 60*4 ] )
ij1 = tf.reshape( tf.one_hot( [i1*4+j1] , 60*4 , dtype=tf.float32 ) , [ 60*4 , 1 ] )
ij2 = tf.reshape( tf.one_hot( [i2*4+j2] , 60*4 , dtype=tf.float32 ) , [ 60*4 , 1 ] )
tf.logical_and( tf.matmul( x_flat , ij1 ) , tf.matmul( x_flat , ij2 ) )
关于python - Tensorflow - 数据维度、占位符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43834529/