diff options
Diffstat (limited to 'Square.lua')
-rw-r--r-- | Square.lua | 33 |
1 files changed, 0 insertions, 33 deletions
diff --git a/Square.lua b/Square.lua deleted file mode 100644 index 30e8cb9..0000000 --- a/Square.lua +++ /dev/null @@ -1,33 +0,0 @@ -local Square, parent = torch.class('nn.Square','nn.Module') - -function Square:__init(args) - parent.__init(self) - if args then - error(xlua.usage('nn.Square', - 'a simple component-wise mapping: square()', - 'sq = nn.Square()\n'.. - 'squared = sq:forward(sometensor)', - {type='nil', help='no arg required'})) - end -end - -function Square:forward(input) - self.output:resizeAs(input):copy(input) - self.output:cmul(input) - return self.output -end - -function Square:backward(input, gradOutput) - self.gradInput:resizeAs(input):copy(gradOutput) - self.gradInput:cmul(input):mul(2) - return self.gradInput -end - - -function Square:write(file) - parent.write(self,file) -end - -function Square:read(file) - parent.read(self,file) -end |