From 4f508adda61df67dc5856b05c46fe37aa84b15b7 Mon Sep 17 00:00:00 2001 From: Sean Naren Date: Sat, 2 Apr 2016 15:57:30 +0100 Subject: Added CTCCriterion docs --- README.md | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/README.md b/README.md index c2d5777..8338124 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,7 @@ This section includes documentation for the following objects: * [SoftMaxTree](#nnx.SoftMaxTree) : a hierarchical log-softmax Module; * [TreeNLLCriterion](#nnx.TreeNLLCriterion) : a negative log-likelihood Criterion for the SoftMaxTree; + * [CTCCriterion](#nnx.CTCCriterion) : a Connectionist Temporal Classification Criterion based on [warp-ctc](https://github.com/baidu-research/warp-ctc); * [PushTable (and PullTable)](#nnx.PushTable) : extracts a table element and inserts it later in the network; * [MultiSoftMax](#nnx.MultiSoftMax) : performs a softmax over the last dimension of a 2D or 3D input; * [SpatialReSampling](#nnx.SpatialReSampling) : performs bilinear resampling of a 3D or 4D input image; @@ -144,6 +145,40 @@ In some cases, this can simplify the digraph of Modules. Note that a PushTable can be associated to many PullTables, but each PullTable is associated to only one PushTable. + +### CTCCriterion ### +``` +criterion = nn.CTCCriterion() +``` +Creates a Criterion based on Baidus' [warp-ctc](https://github.com/baidu-research/warp-ctc) implementation. +This Module measures the loss between a 3D output of (batch x time x inputdim) and a target where there is no alignment of inputs and labels. +Must have installed warp-ctc which can be installed via luarocks: +``` +luarocks install http://raw.githubusercontent.com/baidu-research/warp-ctc/master/torch_binding/rocks/warp-ctc-scm-1.rockspec +``` +Supports cuda via: +``` +criterion = nn.CTCCriterion():cuda() +``` +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}} +ctcCriterion = nn.CTCCriterion() + +print(ctcCriterion:forward(output,label)) + +ctcCriterion = ctcCriterion:cuda() -- Switch to cuda implementation. +output = output:cuda() + +print(ctcCriterion:forward(output,label)) +``` + +gives the output: +``` +4.9038286209106 +4.9038290977478 +``` ### MultiSoftMax ### This Module takes 2D or 3D input and performs a softmax over the last dimension. -- cgit v1.2.3