layer_Fmaps的大小(1,96,236,236) 大小不等(1,96,708,708)
在layer_Fmaps中的每个3乘3矩阵中,只有值为1的单元格应替换为sitwches的相反值
我无法通过使用循环将直接值分配到某个位置来找到解决问题的方法
c.getT()
知道switchs和layer_Fmaps是tensor4
def switchs(layer_Fmaps, step=2, switches):
for idx in range(96):
for i in range(0, 708, step):
for j in range(0, 708, step):
val = layer_Fmaps[0][idx][i/2,j/2]
switches = T.set_subtensor(switches[0][idx][i:i + step, j:j + step],val)
return switches
任何建议都将不胜感激。
答案 0 :(得分:0)
def switchs(layer_Fmaps, switches, step=2):
for idx in range(96):
for i in range(0, 708, step):
for j in range(0, 708, step):
val = layer_Fmaps[0,idx,i/2,j/2]
switches = T.set_subtensor(switches[0, idx, i:i + step, j:j + step],val)
return switches
和
img = np.zeros((1,96,236,236))
sswitchs = np.zeros((1,96,708,708))
inp = T.tensor4('img')
SW = T.tensor4('SW')
tester = switchs(inp,SW, 3)
f = theano.function([inp, SW], tester)
d = f(img,sswitchs)
我修改了几件事: