1
有在tensorflow任何方法都可以实现广播分配矩阵(tf.Variable) 类似下面的代码....tensorflow变量分配广播
a = tf.Variable(np.zeros([10,10,10,10], np.int32))
# creating a mask and trying to assign the 2nd, 3rd dimension of a
mask = tf.ones([10,10])
# 1) which is work in this case, but only assign one block
op = a[0,:,:,0].assign(mask)
# 2) attempting to broadcasting while not work, size mismatch
op = a[0].assign(mask)
我目前的解决方案可能会遍历所有其他尺寸但可能遭受嵌套循环,如1) 或者必须有一个更聪明的方法来做到这一点,谢谢!
什么好的技巧!谢谢!它真的很整齐。 –