Skip to content

Latest commit

 

History

History
63 lines (45 loc) · 2.66 KB

criterion.md

File metadata and controls

63 lines (45 loc) · 2.66 KB

Criterion Modules

Criterions used for handling sequential inputs and targets :

AbstractSequencerCriterion

asc = nn.AbstractSequencerCriterion(stepcriterion, [sizeAverage])

Similar to the stepmodule passed to the AbstractRecurrent constructor, the stepcriterion is internally cloned for each time-step. Unlike the stepmodule the stepcriterion never has any parameters to share.

[criterion] getStepCriterion(step)

Returns a criterion clone of the stepcriterion (stored in self.clones[1]) for a specific time-step.

setZeroMask(zeroMask)

Expects a seqlen x batchsize zeroMask. The zeroMask is then passed to seqlen criterions by indexing zeroMask[step]. When zeroMask=false, the zero-masking is disabled.

SequencerCriterion

This Criterion is a decorator:

c = nn.SequencerCriterion(criterion, [sizeAverage])

Both the input and target are expected to be a sequence, either as a table or Tensor. For each step in the sequence, the corresponding elements of the input and target will be applied to the criterion. The output of forward is the sum of all individual losses in the sequence. This is useful when used in conjunction with a Sequencer.

If sizeAverage is true (default is false), the output loss and gradInput is averaged over each time-step.

RepeaterCriterion

This Criterion is a decorator:

c = nn.RepeaterCriterion(criterion)

The input is expected to be a sequence (table or Tensor). A single target is repeatedly applied using the same criterion to each element in the input sequence. The output of forward is the sum of all individual losses in the sequence. This is useful for implementing models like RCNNs, which are repeatedly presented with the same target.