Python Tensorflow-数据的维度,占位符

Python Tensorflow-数据的维度,占位符,python,machine-learning,tensorflow,Python,Machine Learning,Tensorflow,我是Tensorflow的完全初学者,如果我的问题很琐碎,我很抱歉,但我已经查阅了文档和Google,找不到答案。(我也为我的英语道歉) 我想做点像 sess.run(train, {x:x_train, y:x_train} 其中x_train是一个大小为3190的数组,包含我的输入数据(尺寸为60*4的数组) 我的问题是,x应该是: x = tf.placeholder(tf.bool, [60,4]) 或 ? 第一个给出了以下错误: ValueError: Cannot feed va

我是Tensorflow的完全初学者,如果我的问题很琐碎,我很抱歉,但我已经查阅了文档和Google,找不到答案。(我也为我的英语道歉)

我想做点像

sess.run(train, {x:x_train, y:x_train}
其中x_train是一个大小为3190的数组,包含我的输入数据(尺寸为60*4的数组)

我的问题是,x应该是:

x = tf.placeholder(tf.bool, [60,4])

?

第一个给出了以下错误:

ValueError: Cannot feed value of shape (3190, 60, 4) for Tensor u'Placeholder:0', which has shape '(60, 4)'
如果我使用第二个,我如何用0Do use达到x[I][j]

并供您的逻辑和使用

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 ) )

在这种情况下,你需要一个三维张量。然而,示例
tf.logical_和(x[i1][j1],x[i2][j2])
不够清楚。
i1,j1
i2,j2
之间的关系是什么?你打算计算一个
60*4*60*4
4D张量吗?谢谢你的回答。我的3190输入中的每一个都是一个60*4张量,它代表一个由60个核苷酸组成的DNA序列。每个核苷酸表示为1×4布尔数组,指示该核苷酸是a、C、G还是T(例如,如果在位置30处存在a,则x[30]=[1,0,0,0])。我想对输入执行一些“和”操作,例如“位置3有一个A,位置15有一个C”(x[3][0]和x[15][1])。每个都是1*1张量。我希望这更清楚?谢谢!我添加了一些类型转换(matmul的bool到float32,logical_和的float32到bool),这似乎起到了作用。非常感谢你!请将此答案标记为解决方案@DNAprototype
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 ) )