1
0
Fork 0
mirror of synced 2024-05-17 03:12:18 +12:00

Add w2nn.Print for debug

This commit is contained in:
nagadomi 2018-08-29 05:47:45 +09:00
parent 0fe21eef70
commit 1dc32aaa89
3 changed files with 33 additions and 0 deletions

15
lib/Print.lua Normal file
View file

@ -0,0 +1,15 @@
local Print, parent = torch.class('w2nn.Print','nn.Module')
function Print:__init()
parent.__init(self)
end
function Print:updateOutput(input)
print(input:size())
self.output:resizeAs(input)
self.output:copy(input)
return self.output
end
function Print:updateGradInput(input, gradOutput)
self.gradInput:resizeAs(GradOutput)
return self.gradInput
end

16
lib/PrintTable.lua Normal file
View file

@ -0,0 +1,16 @@
local PrintTable, parent = torch.class('w2nn.PrintTable','nn.Module')
function PrintTable:__init(id)
parent.__init(self)
self.id = id
end
function PrintTable:updateOutput(input)
print("----", self.id)
print(input)
self.output = input
return self.output
end
function PrintTable:updateGradInput(input, gradOutput)
self.gradInput = gradOutput
return self.gradInput
end

View file

@ -75,5 +75,7 @@ else
require 'InplaceClip01'
require 'L1Criterion'
require 'ShakeShakeTable'
require 'PrintTable'
require 'Print'
return w2nn
end