diff options
author | fsuzanomassa <fvsmassa@gmail.com> | 2016-03-14 16:35:49 +0300 |
---|---|---|
committer | fsuzanomassa <fvsmassa@gmail.com> | 2016-03-14 16:35:49 +0300 |
commit | 5331cf733ef0dc3772d5b1bd65ae83da41b46568 (patch) | |
tree | 7cff844e6bf0facd27c293e763d9bcc0980f0632 /View.lua | |
parent | f03d5b713d8c5be42f4941bfee008cbbfdd15236 (diff) |
View reuses the same internal tensors
Allows to keep track of its output, as the tensors won't change at every forward/backward pass
Diffstat (limited to 'View.lua')
-rw-r--r-- | View.lua | 8 |
1 files changed, 3 insertions, 5 deletions
@@ -26,8 +26,6 @@ end function View:__init(...) parent.__init(self) self:resetSize(...) - self.output = nil - self.gradInput = nil self.numInputDims = nil end @@ -79,15 +77,15 @@ end function View:updateOutput(input) local bsz = batchsize(input, self.size, self.numInputDims, self.numElements) if bsz then - self.output = input:view(bsz, table.unpack(self.size:totable())) + self.output:view(input, bsz, table.unpack(self.size:totable())) else - self.output = input:view(self.size) + self.output:view(input, self.size) end return self.output end function View:updateGradInput(input, gradOutput) - self.gradInput = gradOutput:view(input:size()) + self.gradInput:view(gradOutput, input:size()) return self.gradInput end |