CTCLossLayer

CTCLossLayer[]

represents a net layer that computes the connectionist temporal classification loss by comparing a sequence of class probability vectors with a sequence of indices representing the target classes.

Details and Options

  • CTCLossLayer[] represents a net that takes an input sequence of vectors and a target sequence of integers and outputs a real value.
  • CTCLossLayer is typically used inside NetGraph.
  • CTCLossLayer exposes the following ports for use in NetGraph etc.:
  • "Input"a sequence of probability vectors of size c+1
    "Target"a sequence of integers between 1 and c
    "Output"a real number
  • The layer definition is based on Graves et al., "Connectionist Temporal Classification: Labelling Unsegmented Sequence Data with Recurrent Neural Networks", 2006.
  • The input should be a sequence of probability vectors of size c+1 where each vector sums to 1. The last element of each vector represents the probability of a special blank class, with the remaining elements representing the probability of the indexed classes 1 to c. The target is a sequence of integers between 1 and c. The target sequence cannot be longer than the input sequence.
  • CTCLossLayer[][<|"Input"in,"Target"target|>] explicitly computes the output from applying the layer.
  • CTCLossLayer[][<|"Input"->{in1,in2,},"Target"->{target1,target2,}|>] explicitly computes outputs for each of the ini and targeti.
  • The size of the input is usually inferred automatically within a NetGraph.
  • CTCLossLayer[n,"Input"ishape,"Target"tshape] allows the shape of the input and target to be specified. Possible forms for ishape are:
  • NetEncoder[]encoder producing a sequence of vectors
    {len,c+1}sequence of len length-(c+1) vectors
    {len,Automatic}sequence of len vectors whose length is inferred
    {"Varying",c+1}varying number of vectors each of length c+1
    {"Varying",Automatic}varying number of vectors each of inferred length
  • Possible forms for tshape are:
  • NetEncoder[]encoder producing a sequence of integers
    {len2}sequence of len2 integers
    {"Varying"}varying number of integers
    RepeatingElement[Restricted[Integer,c]]varying number of integers in the range 1 to c

Examples

open allclose all

Basic Examples  (2)

Create a CTCLossLayer object:

In[1]:=
Click for copyable input
Out[1]=

Create a CTCLossLayer where the input is a sequence of probability vectors and the target is a sequence of indices:

In[1]:=
Click for copyable input
Out[1]=

Apply it to an input and a target:

In[2]:=
Click for copyable input
Out[2]=

Applications  (1)

Possible Issues  (1)

See Also

SoftmaxLayer  "CTCBeamSearch"  CrossEntropyLossLayer  BasicRecurrentLayer  LongShortTermMemoryLayer  GatedRecurrentLayer  NetGraph

Tutorials

Introduced in 2018
(11.3)