我有一个大小为(64,2,82,1)的Tensorflow张量A,我想用张量B的相应部分替换它的(:,:,80:82,:)部分(也是(64 ,2,82,1)尺寸)。如何用Tensorflow张量中的某些值替换其他张量的值?
我该怎么做?
PS:准确地说,我的意思是看起来像这样在numpy的操作:
A[:, :, 80:82, :] = B[:, :, 80:82, :]
我有一个大小为(64,2,82,1)的Tensorflow张量A,我想用张量B的相应部分替换它的(:,:,80:82,:)部分(也是(64 ,2,82,1)尺寸)。如何用Tensorflow张量中的某些值替换其他张量的值?
我该怎么做?
PS:准确地说,我的意思是看起来像这样在numpy的操作:
A[:, :, 80:82, :] = B[:, :, 80:82, :]
下面的代码可能会帮助你得到一些想法,
a = tf.constant([[11,0,13,14],
[21,22,23,0]])
condition = tf.equal(a, 0)
case_true = tf.reshape(tf.multiply(tf.ones([8], tf.int32), -9999), [2, 4])
case_false = a
a_m = tf.where(condition, case_true, case_false)
sess = tf.Session()
sess.run(a_m)
这里我访问个人元素的tenso [R!
给看看答案在这里https://stackoverflow.com/questions/44648788/how-to-assign-values-to-specified-location-in-tensorflow –
也有在github讨论,HTTPS: //github.com/tensorflow/tensorflow/issues/206,我不明白它是否以及如何解决它... –