2015-11-03 26 views
1

我實現了一個名爲sharedModule的模塊供我自己使用。我已經重寫以下updateGradInput方法:在火炬中覆蓋updateGradInput方法不適用於我自定義的模塊

然而,當我打電話落後的方法我的模塊上,該self.gradInput場未更新
function SharedModule:updateGradInput(input, gradOutput) 
    test_grad = {} 

    print("call updateGradInput") 
    test_input = input 
    test_gradOutput = gradOutput 
    assert(type(gradOutput) == 'table' and #input == #gradOutput) 

    local T = #input 
    for t = 1, T do 
      self.gradInput[t] = self.clones[t]: updateGradInput(input[t], gradOutput[t]) 
      test_grad[t] = self.gradInput[t] 
    end 
    print(#self.gradInput) -- print normal value 
    --self.gradInput = test_grad -- 
    return self.gradInput -- empty, ??? 
    end 

,有什麼問題,任何一個能幫助我嗎?

+0

我檢查這個領域,但有一個空的錯誤發生。但是,當我直接調用updateGradInput方法時,它工作正常 –

回答

1

落後方法將調用名爲updateGradInput和accGradParams兩種方法,結果發現,在因錯別字的accGradParams

相關問題