Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/torch/nn.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'SoftMin.lua')
-rw-r--r--SoftMin.lua15
1 files changed, 15 insertions, 0 deletions
diff --git a/SoftMin.lua b/SoftMin.lua
new file mode 100644
index 0000000..90c6c60
--- /dev/null
+++ b/SoftMin.lua
@@ -0,0 +1,15 @@
+local SoftMin, parent = torch.class('nn.SoftMin', 'nn.Module')
+
+function SoftMin:updateOutput(input)
+ self.mininput = self.mininput or input.new()
+ self.mininput:resizeAs(input):copy(input):mul(-1)
+ return input.nn.SoftMax_updateOutput(self, self.mininput)
+end
+
+function SoftMin:updateGradInput(input, gradOutput)
+ self.mininput = self.mininput or input.new()
+ self.mininput:resizeAs(input):copy(input):mul(-1)
+ self.gradInput = input.nn.SoftMax_updateGradInput(self, self.mininput, gradOutput)
+ self.gradInput:mul(-1)
+ return self.gradInput
+end