functional

Pytorch functions

Combinatorics

pydrobert.torch.functional.binomial_coefficient(length, count)[source]

Compute the binomial coefficients (length choose count)

The binomial coefficient “length choose count” is calculated as

\[\begin{split}\binom{length}{count} = \frac{length!}{length!(length - count)!} \\ x! = \begin{cases} \prod_{x'=1}^x x' & x > 0 \\ 1 & x = 0 \\ 0 & x < 0 \end{cases}\end{split}\]
Parameters:
  • length (Tensor) – A long tensor of the upper terms in the coefficient. Must broadcast with count.

  • count (Tensor) – A long tensor of the lower terms in the coefficient. Must broadcast with length.

Returns:

binom (torch.Tensor) – A long tensor of the broadcasted shape of length and count. The value at multi-index n, binom[n], stores the binomial coefficient length[n] choose count[n], assuming length and count have already been broadcast together.

Warning

As the values in binom can get very large, this function is susceptible to overflow. For example, \(\binom{67}{33}\) exceeds the long’s maximum. Overflow will be avoided by ensuring length does not exceed 66. The binomial coefficient is at its highest when count = length // 2 and at its lowest when count == length or count == 0.

Notes

When the maximum length exceeds 20, the implementation uses the recursion defined in [howard1972].

pydrobert.torch.functional.enumerate_vocab_sequences(length, vocab_size, device=device(type='cpu'), dtype=torch.int64)[source]

Enumerate all sequences of a finite range of values of a fixed length

This function generalizes enumerate_binary_sequences() to any positive vocabulary size. Each step in each sequence takes on a value from 0-vocab_size

Parameters:
  • length (int) – The non-negative length of the vocab sequence.

  • vocab_size (int) – The positive number of values in the vocabulary.

  • device (device) – What device to return the tensor on.

  • dtype (int) – The data type of the returned tensor.

Returns:

support (torch.Tensor) – A tensor of shape (vocab_size ** length, length) of all possible sequences with that vocabulary. The sequences are ordered such that all configurations where support[s, t] > 0 must follow those where support[s', t] == 0 (i.e. it implies s' < s). Therefore all sequences of length length - x are contained in support[2 ** (length - x), :length - x].

pydrobert.torch.functional.enumerate_binary_sequences(length, device=device(type='cpu'), dtype=torch.int64)[source]

Enumerate all binary sequences of a fixed length

Parameters:
  • length (int) – The non-negative length of the binary sequences.

  • device (device) – What device to return the tensor on.

  • dtype (int) – The data type of the returned tensor.

Returns:

support (torch.Tensor) – A tensor of shape (2 ** length, length) of all possible binary sequences of length length. The sequences are ordered such that all configurations where support[s, t] == 1 must follow those where support[s', t] == 0 (i.e. it implies s' < s). Therefore all binary sequences of length length - x are contained in support[2 ** (length - x), :length - x].

Examples

>>> support = enumerate_binary_sequences(3)
>>> print(support)
tensor([[0, 0, 0],
    [1, 0, 0],
    [0, 1, 0],
    [1, 1, 0],
    [0, 0, 1],
    [1, 0, 1],
    [0, 1, 1],
    [1, 1, 1]])
>>> print(support[:4, :2])
tensor([[0, 0],
    [1, 0],
    [0, 1],
    [1, 1]])
pydrobert.torch.functional.enumerate_binary_sequences_with_cardinality(length, count, device=device(type='cpu'), dtype=torch.int64)[source]

Enumerate the configurations of binary sequences with fixed sum

Parameters:
  • length (Any) – The number of elements in the binary sequence. Either a tensor or an int. Must be the same type as count. If a tensor, must broadcast with count.

  • count (Any) – The number of elements with value 1. Either a tensor or an int. Must be the same type as length. If a tensor, must broadcast with length.

  • device (device) – If length and count are integers, device specifies the device to return the tensor on. Otherwise the device of length is used.

  • dtype (int) – If length and count are integers, dtype specifies the return type of the tensor. Otherwise the type of length is used.

Returns:

support (torch.Tensor or tuple of torch.Tensor) – If length and count are both integers, support is a tensor of shape (N, length) where \(N = \binom{length}{count}\) is the number of unique binary sequence configurations of length length such that for any n, support[n].sum() == count.

If length and count are both long tensors, support is a tuple of tensors support_, binom where support_ is of shape (B*, N_, length_) and binom is of shape (B*). B* refers to the broadcasted shape of length and count, N_ is the maximum value in binom, and length_ is the maximum value in length_. For multi-index b, support[b] stores the unique binary sequence configurations for length[b] and count[b]. binom[b] stores the number of unique configurations for length[b] and count[b], which is always \(\binom{length[b]}{count[b]}\). Sequences are right-padded to the maximum length and count: for index b, only values in support[b, :binom[b], :length[b]] are valid.

Warning

The size of the returned support grows exponentially with length.

pydrobert.torch.functional.simple_random_sampling_without_replacement(total_count, given_count, out_size=None)[source]

Draw a binary vector with uniform probabilities but fixed cardinality

Uses the algorithm proposed in [fan1962].

Parameters:
  • total_count (Tensor) – The nonnegative sizes of the individual binary vectors. Must broadcast with given_count.

  • given_count (Tensor) – The cardinalities of the individual binary vectors. Must broadcast with and not exceed the values of total_count.

  • out_size (Optional[int]) – The vector size. Must be at least the value of total_count.max(). If unset, will default to that value.

Returns:

b (torch.Tensor) – A sample tensor of shape (*, out_size), where (*,) is the broadcasted shape of total_count and given_count. The final dimension is the vector dimension. The n-th vector of b is right-padded with zero for all values exceeding total_count[n], i.e. b[n, total_count[n]:].sum() == 0. The remaining total_count[n] elements of the vector sum to associated given count, i.e. b[n, :total_count[n]].sum() == given_count[n].

See also

pydrobert.torch.distributions.SimpleRandomSamplingWithoutReplacement

For information on the distribution.

Decoding

pydrobert.torch.functional.beam_search_advance(log_probs_t, width, log_probs_prev, y_prev, y_prev_lens=None)[source]

Beam search step function

Parameters:
  • log_probs_t (Tensor) – A tensor of shape (N, old_width, V) containing the log probabilities of extending a given path with a token of a given type in the vocabulary.

  • width (int) – The beam width

  • log_probs_prev (Tensor) – A tensor of shape (N, old_width) containing the log probabilities of the paths so far.

  • y_prev (Tensor) – A tensor of shape (S, N, old_width) containing the path prefixes.

  • y_prev_lens (Optional[Tensor]) – A tensor of shape (N, old_width) specifying the lengths of the prefixes. For batch element n and path k in the beam, only the values y_prev[:y_prev_lens[n, k], n, k] are valid. If unspecified, it is assumed y_prev_lens[:, :] == S.

Returns:

  • y_next, y_next_lens, log_probs_next (torch.Tensor) – The *next* tensors can be interpreted in the same way as their *prev* counterparts, but after the step. The old_width dimension has been replaced with width. y_next is of shape either (S, N, width) or (S + 1, N, width), depending on whether y_prev needed to grow in order to accommodate the newest tokens in the path.

  • next_src (torch.Tensor) – A long tensor of shape (N, width) such that the value k_old = next_src[n, k_new] is the index from the previous step (over old_width) that is a prefix of the new path at k_new (i.e. its source).

Warning

This function has been drastically simplified after v0.3.0. The logic for end-of-sequence handling has been punted to the encapsulating search module.

If there are too few possible extensions to fill the beam, undefined paths will be added to the end of the beam with probability -float('inf'). This means that an invalid path cannot be distibguished from a 0-probability path. Consider using a very negative value as a replacement for log 0, e.g. log_probs_t = log_probs_t.clamp(min=torch.finfo(torch.float).min / 2).

See also

pydrobert.torch.modules.BeamSearch

For the full beam search.

Functional version of CTCGreedySearch

This function accepts both the arguments initializing a CTCGreedySearch instance and the inputs to its call and outputs the return value of the call.

Parameters:
Returns:

typing.Tuple[torch.Tensor, torch.Tensor, torch.Tensor]

See also

pydrobert.torch.modules.CTCGreedySearch

For a description of what this does, its inputs, and its outputs.

pydrobert.torch.functional.ctc_prefix_search_advance(probs_t, width, probs_prev, y_prev, y_prev_last, y_prev_lens, prev_is_prefix)[source]

CTC prefix search step function

The step function of the CTC prefix search.

Parameters:
  • probs_t (Tuple[Tensor, Tensor, Tensor]) – A triple of ext_probs_t, nonext_probs_t, blank_probs_t. ext_probs_t is of shape (N, old_width, V) containing the probabilities of extending a prefix with a token of each type (resulting in a new token being added to the reduced transcription). nonext_probs_t has shape (N, V) and contains the probabilities of adding a token that does not extend a given prefix (i.e. when a token immediately follows another of the same type with no blanks in between). blank_probs_t is of shape (N) and contains the blank label probabilities.

  • width (int) – The beam width.

  • probs_prev (Tuple[Tensor, Tensor]) – A pair of nb_probs_prev, b_probs_prev. Each is a tensor of shape (N, old_width). nb_probs_prev contains the summed mass of the paths reducing to the given prefix which end in a non-blank token. b_probs_prev is the summed mass of the paths reducing to the given prefix which end in a blank token. nb_probs_prev + b_probs_prev = probs_prev, the total mass of each prefix.

  • y_prev (Tensor) – A long tensor of shape (S, N, old_width) containing the (reduced) prefixes of each path.

  • y_prev_last (Tensor) – A long tensor of shape (N, old_width) containing the last token in each prefix. Arbitrary when the prefix is length 0.

  • y_prev_lens (Tensor) – A long tensor of shape (N, old_width) specifying the length of each prefix. For batch element n and prefix k, only the tokens in y_prev[:y_prev_lens[n, k], n, k] are valid.

  • prev_is_prefix (Tensor) – A boolean tensor of shape (N, old_width, old_width). prev_is_prefix[n, k, k'] if and only if prefix k is a (non-strict) prefix of k'

Returns:

  • y_next, y_next_last, y_next_lens, probs_next, next_is_prefix (torch.Tensor) – The *next* tensors are analogous to the *prev* arguments, but after the step is completed.

  • next_src (torch.Tensor) – A long tensor of shape (N, width) such that the value k_old = next_src[n, k_new] is the index from the previous step (over old_width) that is a prefix of the new prefix at k_new (i.e. its source).

  • next_is_nonext (torch.Tensor) – A boolean tensor indicating if the new prefix did _not_ extend its source. If true, the new prefix is identical to the source. If false, it has one token more.

See also

pydrobert.torch.modules.CTCPrefixSearch

Performs the entirety of the search.

Warning

This function treats large widths the same as pydrobert.torch.modules.CTCPrefixSearch(): the beam will be filled to width but invalid prefixes will be assigned a total probability of -float("inf"). However, this function will only set the non-blank probabilities of invalid prefixes to negative infinity; blank probabilities of invalid prefixes may be 0 instead. The total (summed) mass will still be -float("inf").

Notes

If an extending prefix matches a previous nonextending prefix, the former’s mass is absorbed into the latter’s and the latter’s path is invalidated (see warning).

pydrobert.torch.functional.random_walk_advance(log_probs_t, log_probs_prev, y_prev, y_prev_lens=None)[source]

Random walk step function

Parameters:
  • log_probs_t (Tensor) – A tensor of shape (N, V) containing the log probabilities of extending a given path with a token of a given type in the vocabulary.

  • log_probs_prev (Tensor) – A tensor of shape (N,) containing the log probablities of the paths so far.

  • y_prev (Tensor) – A tensor of shape (S, N) containing the paths so far.

  • y_prev_lens (Optional[Tensor]) – A tensor of shape (N,) specifying the lengths of the prefixes. For batch element n, only the values y_prev[:y_prev_lens[n], n] are valid. If unspecified, it is assumed that y_prev_lens[:] == S.

Returns:

y_next, log_probs_next (torch.Tensor) – The *next** tensors can be interpreted in the same way as their *prev* counterparts, but after the step. y_next is of shape either (S, N) or (S + 1, N), depending on whether the size of y_prev needed to grow in order to accommodate the newest token in the path. Note the next path lengths are always the previous path lengths plus one, i.e. y_next_lens = y_prev_lens + 1.

Warning

This function has been drastically simplified after v0.3.0. The logic for end-of-sequence handling has been punted to the encapsulating search module. The logic for the relaxation has been entirely removed given the revamp of pydrobert.torch.estimators.

See also

pydrobert.torch.modules.RandomWalk

For the full random walk.

pydrobert.torch.functional.sequence_log_probs(logits, hyp, dim=0, eos=None)[source]

Functional version of SequentialLogProbabilities

This function accepts both the arguments initializing a SequentialLogProbabilities instance and the inputs to its call and outputs the return value of the call.

Parameters:
Returns:

<class 'torch.Tensor'>

See also

pydrobert.torch.modules.SequentialLogProbabilities

For a description of what this does, its inputs, and its outputs.

Features

pydrobert.torch.functional.chunk_by_slices(x, slices, lens=None, mode='constant', value=0.0)[source]

Functional version of ChunkBySlices

This function accepts both the arguments initializing a ChunkBySlices instance and the inputs to its call and outputs the return value of the call.

Parameters:
Returns:

typing.Tuple[torch.Tensor, torch.Tensor]

See also

pydrobert.torch.modules.ChunkBySlices

For a description of what this does, its inputs, and its outputs.

pydrobert.torch.functional.chunk_token_sequences_by_slices(refs, slices, ref_lens=None, partial=False, retain=False)[source]

Functional version of ChunkTokenSequencesBySlices

This function accepts both the arguments initializing a ChunkTokenSequencesBySlices instance and the inputs to its call and outputs the return value of the call.

Parameters:
Returns:

typing.Tuple[torch.Tensor, torch.Tensor]

See also

pydrobert.torch.modules.ChunkTokenSequencesBySlices

For a description of what this does, its inputs, and its outputs.

pydrobert.torch.functional.dense_image_warp(image, flow, indexing='hw', mode='bilinear', padding_mode='border')[source]

Functional version of DenseImageWarp

This function accepts both the arguments initializing a DenseImageWarp instance and the inputs to its call and outputs the return value of the call.

Parameters:
Returns:

<class 'torch.Tensor'>

See also

pydrobert.torch.modules.DenseImageWarp

For a description of what this does, its inputs, and its outputs.

pydrobert.torch.functional.feat_deltas(x, dim=-1, time_dim=-2, concatenate=True, order=2, width=2, pad_mode='replicate', value=0.0, _filters=None)[source]

Functional version of FeatureDeltas

This function accepts both the arguments initializing a FeatureDeltas instance and the inputs to its call and outputs the return value of the call.

Parameters:
Returns:

<class 'torch.Tensor'>

See also

pydrobert.torch.modules.FeatureDeltas

For a description of what this does, its inputs, and its outputs.

pydrobert.torch.functional.mean_var_norm(x, dim=-1, mean=None, std=None, eps=1.1754943508222875e-38)[source]

Functional version of MeanVarianceNormalization

This function accepts both the arguments initializing a MeanVarianceNormalization instance and the inputs to its call and outputs the return value of the call.

Parameters:

See also

pydrobert.torch.modules.MeanVarianceNormalization

For a description of what this does, its inputs, and its outputs.

pydrobert.torch.functional.pad_masked_sequence(x, mask, batch_first=False, padding_value=0.0)[source]

Functional version of PadMaskedSequence

This function accepts both the arguments initializing a PadMaskedSequence instance and the inputs to its call and outputs the return value of the call.

Parameters:
Returns:

typing.Tuple[torch.Tensor, torch.Tensor]

See also

pydrobert.torch.modules.PadMaskedSequence

For a description of what this does, its inputs, and its outputs.

pydrobert.torch.functional.pad_variable(x, lens, pad, mode='constant', value=0.0)[source]

Functional version of PadVariable

This function accepts both the arguments initializing a PadVariable instance and the inputs to its call and outputs the return value of the call.

Parameters:
Returns:

<class 'torch.Tensor'>

See also

pydrobert.torch.modules.PadVariable

For a description of what this does, its inputs, and its outputs.

pydrobert.torch.functional.polyharmonic_spline(train_points, train_values, query_points, order, regularization_weight=0.0, full_matrix=True)[source]

Functional version of PolyharmonicSpline

This function accepts both the arguments initializing a PolyharmonicSpline instance and the inputs to its call and outputs the return value of the call.

Parameters:
  • train_points (Tensor) –

  • train_values (Tensor) –

  • query_points (Tensor) –

  • order (int) –

  • regularization_weight (float) –

  • full_matrix (bool) –

Returns:

<class 'torch.Tensor'>

See also

pydrobert.torch.modules.PolyharmonicSpline

For a description of what this does, its inputs, and its outputs.

pydrobert.torch.functional.random_shift(input, in_lens, prop, mode, value, training=True)[source]

Functional version of RandomShift

This function accepts both the arguments initializing a RandomShift instance and the inputs to its call and outputs the return value of the call.

Parameters:
Returns:

typing.Tuple[torch.Tensor, torch.Tensor]

See also

pydrobert.torch.modules.RandomShift

For a description of what this does, its inputs, and its outputs.

pydrobert.torch.functional.slice_spect_data(input, in_lens=None, other_lens=None, policy='fixed', window_type='symmetric', valid_only=True, lobe_size=0)[source]

Functional version of SliceSpectData

This function accepts both the arguments initializing a SliceSpectData instance and the inputs to its call and outputs the return value of the call.

Parameters:
Returns:

typing.Tuple[torch.Tensor, torch.Tensor]

See also

pydrobert.torch.modules.SliceSpectData

For a description of what this does, its inputs, and its outputs.

pydrobert.torch.functional.sparse_image_warp(image, source_points, dest_points, indexing='hw', field_interpolation_order=2, field_regularization_weight=0.0, field_full_matrix=True, pinned_boundary_points=0, dense_interpolation_mode='bilinear', dense_padding_mode='border', include_flow=True)[source]

Functional version of SparseImageWarp

This function accepts both the arguments initializing a SparseImageWarp instance and the inputs to its call and outputs the return value of the call.

Parameters:
  • image (Tensor) –

  • source_points (Tensor) –

  • dest_points (Tensor) –

  • indexing (str) –

  • field_interpolation_order (int) –

  • field_regularization_weight (float) –

  • field_full_matrix (bool) –

  • pinned_boundary_points (int) –

  • dense_interpolation_mode (str) –

  • dense_padding_mode (str) –

  • include_flow (bool) –

Returns:

typing.Any

See also

pydrobert.torch.modules.SparseImageWarp

For a description of what this does, its inputs, and its outputs.

pydrobert.torch.functional.spec_augment(feats, max_time_warp, max_freq_warp, max_time_mask, max_freq_mask, max_time_mask_proportion, num_time_mask, num_time_mask_proportion, num_freq_mask, interpolation_order, lengths=None, training=True)[source]

Functional version of SpecAugment

This function accepts both the arguments initializing a SpecAugment instance and the inputs to its call and outputs the return value of the call.

Parameters:
  • feats (Tensor) –

  • max_time_warp (float) –

  • max_freq_warp (float) –

  • max_time_mask (int) –

  • max_freq_mask (int) –

  • max_time_mask_proportion (float) –

  • num_time_mask (int) –

  • num_time_mask_proportion (float) –

  • num_freq_mask (int) –

  • interpolation_order (int) –

  • lengths (Optional[Tensor]) –

  • training (bool) –

Returns:

<class 'torch.Tensor'>

See also

pydrobert.torch.modules.SpecAugment

For a description of what this does, its inputs, and its outputs.

pydrobert.torch.functional.spec_augment_apply_parameters(feats, params, interpolation_order, lengths=None)[source]

Functional version of SpecAugment.apply_parameters

This function accepts both the arguments initializing a SpecAugment.apply_parameters instance and the inputs to its call and outputs the return value of the call.

Parameters:
Returns:

<class 'torch.Tensor'>

See also

pydrobert.torch.modules.SpecAugment.apply_parameters

For a description of what this does, its inputs, and its outputs.

pydrobert.torch.functional.spec_augment_draw_parameters(feats, max_time_warp, max_freq_warp, max_time_mask, max_freq_mask, max_time_mask_proportion, num_time_mask, num_time_mask_proportion, num_freq_mask, lengths=None)[source]

Functional version of SpecAugment.draw_parameters

This function accepts both the arguments initializing a SpecAugment.draw_parameters instance and the inputs to its call and outputs the return value of the call.

Parameters:
  • feats (Tensor) –

  • max_time_warp (float) –

  • max_freq_warp (float) –

  • max_time_mask (int) –

  • max_freq_mask (int) –

  • max_time_mask_proportion (float) –

  • num_time_mask (int) –

  • num_time_mask_proportion (float) –

  • num_freq_mask (int) –

  • lengths (Optional[Tensor]) –

Returns:

typing.Tuple[typing.Optional[torch.Tensor], typing.Optional[torch.Tensor], typing.Optional[torch.Tensor], typing.Optional[torch.Tensor], typing.Optional[torch.Tensor], typing.Optional[torch.Tensor], typing.Optional[torch.Tensor], typing.Optional[torch.Tensor]]

See also

pydrobert.torch.modules.SpecAugment.draw_parameters

For a description of what this does, its inputs, and its outputs.

pydrobert.torch.functional.warp_1d_grid(src, flow, lengths, max_length=None, interpolation_order=1)[source]

Functional version of Warp1DGrid

This function accepts both the arguments initializing a Warp1DGrid instance and the inputs to its call and outputs the return value of the call.

Parameters:
Returns:

<class 'torch.Tensor'>

See also

pydrobert.torch.modules.Warp1DGrid

For a description of what this does, its inputs, and its outputs.

Reinforcement Learning

pydrobert.torch.functional.time_distributed_return(r, gamma, batch_first=False)[source]

Functional version of TimeDistributedReturn

This function accepts both the arguments initializing a TimeDistributedReturn instance and the inputs to its call and outputs the return value of the call.

Parameters:
Returns:

<class 'torch.Tensor'>

See also

pydrobert.torch.modules.TimeDistributedReturn

For a description of what this does, its inputs, and its outputs.

String Matching

pydrobert.torch.functional.edit_distance(ref, hyp, eos=None, include_eos=False, norm=False, batch_first=False, ins_cost=1.0, del_cost=1.0, sub_cost=1.0, warn=True)[source]

Functional version of EditDistance

This function accepts both the arguments initializing a EditDistance instance and the inputs to its call and outputs the return value of the call.

Parameters:
Returns:

<class 'torch.Tensor'>

See also

pydrobert.torch.modules.EditDistance

For a description of what this does, its inputs, and its outputs.

pydrobert.torch.functional.error_rate(ref, hyp, eos=None, include_eos=False, norm=True, batch_first=False, ins_cost=1.0, del_cost=1.0, sub_cost=1.0, warn=True)[source]

Functional version of ErrorRate

This function accepts both the arguments initializing a ErrorRate instance and the inputs to its call and outputs the return value of the call.

Parameters:
Returns:

<class 'torch.Tensor'>

See also

pydrobert.torch.modules.ErrorRate

For a description of what this does, its inputs, and its outputs.

pydrobert.torch.functional.fill_after_eos(tokens, eos, dim=0, fill=None, value=None)[source]

Functional version of FillAfterEndOfSequence

This function accepts both the arguments initializing a FillAfterEndOfSequence instance and the inputs to its call and outputs the return value of the call.

Parameters:
Returns:

<class 'torch.Tensor'>

See also

pydrobert.torch.modules.FillAfterEndOfSequence

For a description of what this does, its inputs, and its outputs.

pydrobert.torch.functional.hard_optimal_completion_distillation_loss(logits, ref, hyp, eos=None, include_eos=True, batch_first=False, ins_cost=1.0, del_cost=1.0, sub_cost=1.0, weight=None, reduction='mean', ignore_index=-2, warn=True)[source]

Functional version of HardOptimalCompletionDistillationLoss

This function accepts both the arguments initializing a HardOptimalCompletionDistillationLoss instance and the inputs to its call and outputs the return value of the call.

Parameters:
Returns:

<class 'torch.Tensor'>

See also

pydrobert.torch.modules.HardOptimalCompletionDistillationLoss

For a description of what this does, its inputs, and its outputs.

pydrobert.torch.functional.minimum_error_rate_loss(log_probs, ref, hyp, eos=None, include_eos=True, sub_avg=True, batch_first=False, norm=True, ins_cost=1.0, del_cost=1.0, sub_cost=1.0, reduction='mean', warn=True)[source]

Functional version of MinimumErrorRateLoss

This function accepts both the arguments initializing a MinimumErrorRateLoss instance and the inputs to its call and outputs the return value of the call.

Parameters:
Returns:

<class 'torch.Tensor'>

See also

pydrobert.torch.modules.MinimumErrorRateLoss

For a description of what this does, its inputs, and its outputs.

pydrobert.torch.functional.optimal_completion(ref, hyp, eos=None, include_eos=True, batch_first=False, ins_cost=1.0, del_cost=1.0, sub_cost=1.0, padding=-100, exclude_last=False, warn=True)[source]

Functional version of OptimalCompletion

This function accepts both the arguments initializing a OptimalCompletion instance and the inputs to its call and outputs the return value of the call.

Parameters:
Returns:

<class 'torch.Tensor'>

See also

pydrobert.torch.modules.OptimalCompletion

For a description of what this does, its inputs, and its outputs.

pydrobert.torch.functional.prefix_edit_distances(ref, hyp, eos=None, include_eos=True, norm=False, batch_first=False, ins_cost=1.0, del_cost=1.0, sub_cost=1.0, padding=-100, exclude_last=False, warn=True)[source]

Functional version of PrefixEditDistances

This function accepts both the arguments initializing a PrefixEditDistances instance and the inputs to its call and outputs the return value of the call.

Parameters:
Returns:

<class 'torch.Tensor'>

See also

pydrobert.torch.modules.PrefixEditDistances

For a description of what this does, its inputs, and its outputs.

pydrobert.torch.functional.prefix_error_rates(ref, hyp, eos=None, include_eos=True, norm=True, batch_first=False, ins_cost=1.0, del_cost=1.0, sub_cost=1.0, padding=-100, exclude_last=False, warn=True)[source]

Functional version of PrefixErrorRates

This function accepts both the arguments initializing a PrefixErrorRates instance and the inputs to its call and outputs the return value of the call.

Parameters:
Returns:

<class 'torch.Tensor'>

See also

pydrobert.torch.modules.PrefixErrorRates

For a description of what this does, its inputs, and its outputs.