c54c430da19670cb030e32558b6810d04767dd99,allennlp/nn/util.py,,sort_batch_by_length,#Any#Any#,26

Before Change


        Indices into the sorted_tensor such that ``sorted_tensor[restoration_indices] == original_tensor``
    
    sorted_sequence_lengths, permutation_index = sequence_lengths.sort(0, descending=True)
    sorted_tensor = tensor[permutation_index]
    // This is the equivalent of zipping with index, sorting by the original
    // sequence lengths and returning the now sorted indices.
    index_range = torch.range(0, len(sequence_lengths) - 1).long()
    _, reverse_mapping = permutation_index.sort(0, descending=False)

After Change


        ``sorted_tensor.index_select(0, restoration_indices) == original_tensor``
    

    if not isinstance(tensor, Variable) or not isinstance(sequence_lengths, Variable):
        raise ConfigurationError("Both the tensor and sequence lengths must be torch.autograd.Variables.")

    sorted_sequence_lengths, permutation_index = sequence_lengths.sort(0, descending=True)
    sorted_tensor = tensor.index_select(0, permutation_index)
    // This is the equivalent of zipping with index, sorting by the original
    // sequence lengths and returning the now sorted indices.
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 5

Instances


Project Name: allenai/allennlp
Commit Name: c54c430da19670cb030e32558b6810d04767dd99
Time: 2017-08-03
Author: markn@allenai.org
File Name: allennlp/nn/util.py
Class Name:
Method Name: sort_batch_by_length


Project Name: allenai/allennlp
Commit Name: 2c4a6e537126f4123de7c97f30587310d3712c06
Time: 2017-09-13
Author: mattg@allenai.org
File Name: allennlp/data/token_indexers/token_characters_indexer.py
Class Name: TokenCharactersIndexer
Method Name: count_vocab_items


Project Name: allenai/allennlp
Commit Name: 2c4a6e537126f4123de7c97f30587310d3712c06
Time: 2017-09-13
Author: mattg@allenai.org
File Name: allennlp/data/token_indexers/token_characters_indexer.py
Class Name: TokenCharactersIndexer
Method Name: token_to_indices