假设我有三个张量,例如:
import keras as K
R=K.zeros((4,4)) # tensor where I want to insert 1-D arrays
T=K.constant([0,1,2,3]) #tensor with indexes where I should replace in R
V=K.constant([[1,1,0,0],[4,3,2,0],[2,1,0,0],[3,2,1,0]]) #tensor with 1-D arrays
# do something
# result
'''
array([[1,1,0,0], <- insert [1,1,0,0] at index 0
[0,4,3,2], <- insert [4,3,2,0] at index 1
[0,0,2,1], <- insert [2,1,0,0] at index 2
[0,0,0,3] <- insert [3,2,1,0] at index 2
]])
'''
如果尺寸超出尺寸,我们丢失一维数组中的某些元素就可以了。 有什么想法吗?我正在使用tensorflow1.8.0