Skip to content

list_field

allennlp.data.fields.list_field

[SOURCE]


ListField

class ListField(SequenceField[DataArray]):
 | def __init__(self, field_list: Sequence[Field]) -> None

A ListField is a list of other fields. You would use this to represent, e.g., a list of answer options that are themselves TextFields.

This field will get converted into a tensor that has one more mode than the items in the list. If this is a list of TextFields that have shape (num_words, num_characters), this ListField will output a tensor of shape (num_sentences, num_words, num_characters).

Parameters

  • field_list : List[Field]
    A list of Field objects to be concatenated into a single input tensor. All of the contained Field objects must be of the same type.

__iter__

class ListField(SequenceField[DataArray]):
 | ...
 | def __iter__(self) -> Iterator[Field]

count_vocab_items

class ListField(SequenceField[DataArray]):
 | ...
 | def count_vocab_items(self, counter: Dict[str, Dict[str, int]])

index

class ListField(SequenceField[DataArray]):
 | ...
 | def index(self, vocab: Vocabulary)

get_padding_lengths

class ListField(SequenceField[DataArray]):
 | ...
 | def get_padding_lengths(self) -> Dict[str, int]

sequence_length

class ListField(SequenceField[DataArray]):
 | ...
 | def sequence_length(self) -> int

as_tensor

class ListField(SequenceField[DataArray]):
 | ...
 | def as_tensor(self, padding_lengths: Dict[str, int]) -> DataArray

empty_field

class ListField(SequenceField[DataArray]):
 | ...
 | def empty_field(self)

batch_tensors

class ListField(SequenceField[DataArray]):
 | ...
 | def batch_tensors(self, tensor_list: List[DataArray]) -> DataArray

human_readable_repr

class ListField(SequenceField[DataArray]):
 | ...
 | def human_readable_repr(self) -> List[Any]