1 回答
TA贡献1808条经验 获得超4个赞
那是你想要的吗?我只使用了这两个测试用例。
x = tf.constant([[1, 2, 3, 4, 5, 6], [1, 2, 3, 4, 5, 1]])
y = tf.constant([[1, 2, 3, 4, 3, 6], [1, 2, 3, 4, 5, 1]])
# x = tf.constant([[1, 2], [4, 5], [7, 7]])
# y = tf.constant([[7, 7], [3, 5]])
def match(xiterations, yiterations, yvalues, xvalues ):
for i in range(xiterations):
for j in range(yiterations):
if (np.array_equal(yvalues[j], xvalues[i])):
print( yvalues[j])
with tf.Session() as sess:
xindex = tf.where( x > 4 )
yindex = tf.where( y > 4 )
xvalues = xindex.eval()
yvalues = yindex.eval()
xiterations = tf.shape(xvalues)[0].eval()
yiterations = tf.shape(yvalues)[0].eval()
print(tf.shape(xvalues)[0].eval())
print(tf.shape(yvalues)[0].eval())
if tf.shape(xvalues)[0].eval() >= tf.shape(yvalues)[0].eval():
match( xiterations, yiterations, yvalues, xvalues)
else:
match( yiterations, xiterations, xvalues, yvalues)
添加回答
举报