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

github.com/clementfarabet/lua---nnx.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSoumith Chintala <soumith@gmail.com>2016-07-27 09:04:42 +0300
committerGitHub <noreply@github.com>2016-07-27 09:04:42 +0300
commitc3df4fbe7b7e18c41f120d461e08be8373ba8376 (patch)
treeea4a201ef9f58a7fe1f9934525382e48a08ab6f7
parent12283921cd4678e799296b5d35c929b0aa6b4a0e (diff)
parentb35c96e1b6982bb18778ddf73a71f38704bbe197 (diff)
Merge pull request #64 from NightFury13/master
update README.md for changes in CTCCriterion.lua
-rw-r--r--README.md32
1 files changed, 28 insertions, 4 deletions
diff --git a/README.md b/README.md
index 422a758..a05035d 100644
--- a/README.md
+++ b/README.md
@@ -165,20 +165,44 @@ Example:
```
output = torch.Tensor({{{1,2,3,4,5},{6,7,8,9,10}}}) -- Tensor of size 1x1x5 (batch x time x inputdim).
label = {{1,3}}
+sizes = torch.Tensor({2}) -- Size of each sequence (sequence-length) in the batch as a tensor
ctcCriterion = nn.CTCCriterion()
-print(ctcCriterion:forward(output,label))
+err = ctcCriterion:forward(output,label,sizes)
+gradOut = ctcCriterion:backward(output,label)
+print("----CPU----")
+print("Error : " .. err)
+print("Gradients :")
+print(gradOut)
ctcCriterion = ctcCriterion:cuda() -- Switch to cuda implementation.
output = output:cuda()
-print(ctcCriterion:forward(output,label))
+err = ctcCriterion:forward(output,label,sizes)
+gradOut = ctcCriterion:backward(output,label)
+print("----GPU----")
+print("Error : " .. err)
+print("Gradients :")
+print(gradOut)
```
gives the output:
```
-4.9038286209106
-4.9038290977478
+----CPU----
+Error : 4.9038286209106
+Gradients :
+(1,.,.) =
+ 0.0117 -0.9683 0.0861 0.2341 0.6364
+ 0.0117 0.0317 0.0861 -0.7659 0.6364
+[torch.FloatTensor of size 1x2x5]
+
+----GPU----
+Error : 4.9038290977478
+Gradients :
+(1,.,.) =
+ 0.0117 -0.9683 0.0861 0.2341 0.6364
+ 0.0117 0.0317 0.0861 -0.7659 0.6364
+[torch.CudaTensor of size 1x2x5]
```
<a name='nnx.MultiSoftMax'/>
### MultiSoftMax ###