01e2ad83afd612d5ebbb5ef93d0004a4d6dfd9a1,allennlp/data/token_indexers/pretrained_transformer_indexer.py,PretrainedTransformerIndexer,as_padded_tensor_dict,#PretrainedTransformerIndexer#Any#Any#,193
Before Change
pad_sequence_to_length(val, padding_lengths[key], default_value=lambda: False)
)
else:
tensor = torch.LongTensor(
pad_sequence_to_length(
val,
padding_lengths[key],
default_value=lambda: 0
if key == "type_ids"
else self._tokenizer.pad_token_id,
),
)
tensor_dict[key] = tensor
return tensor_dict
def __eq__(self, other):
After Change
) -> Dict[str, torch.Tensor]:
tensor_dict = {}
for key, val in tokens.items():
if key == "type_ids":
padding_value = 0
mktensor = torch.LongTensor
elif key == "mask":
padding_value = False
mktensor = torch.BoolTensor
elif len(val) > 0 and isinstance(val[0], bool):
padding_value = False
mktensor = torch.BoolTensor
else:
padding_value = self._tokenizer.pad_token_id
mktensor = torch.LongTensor
tensor = mktensor(
pad_sequence_to_length(
val, padding_lengths[key], default_value=lambda: padding_value
)
In pattern: SUPERPATTERN
Frequency: 3
Non-data size: 6
Instances
Project Name: allenai/allennlp
Commit Name: 01e2ad83afd612d5ebbb5ef93d0004a4d6dfd9a1
Time: 2020-03-31
Author: dirkg@allenai.org
File Name: allennlp/data/token_indexers/pretrained_transformer_indexer.py
Class Name: PretrainedTransformerIndexer
Method Name: as_padded_tensor_dict
Project Name: facebookresearch/ParlAI
Commit Name: 5887e2a96c9511669612ec64311622626c0640d9
Time: 2018-05-29
Author: vgonzalez@fb.com
File Name: parlai/agents/torch_agent/torch_agent.py
Class Name: TorchAgent
Method Name: vectorize
Project Name: dmlc/dgl
Commit Name: 02d3197407487646dc5ca6abd889b8fe5fed1aef
Time: 2020-06-27
Author: zhengda1936@gmail.com
File Name: examples/pytorch/graphsage/train_sampling.py
Class Name:
Method Name: