簡體   English   中英

如何更改阻止循環的theano張量中的子集值?

[英]How can I change subsets value in theano tensor impeded into loop?

大小(1,96,236,236)的layer_Fmaps大小(1,96,708,708)的小地圖

在layer_Fmaps的每個3 x 3矩陣中,只有一個值為1的單元格應由相反的情景

我找不到通過使用循環將直接值分配給特定位置來解決問題的方法

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

知道switch和layer_Fmaps是tensor4

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,3,SW)

f = theano.function([inp, SW], tester)    

d = f(img,sswitchs)

任何建議,將不勝感激。

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)

我修改了幾件事:

  • 將96替換為69。我猜“ 96”是一個錯字。
  • 統一索引
  • 關鍵論點應在結尾。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM