Instance(fields: typing.Dict[str, allennlp.data.fields.field.Field]) → None¶
Instanceis a collection of
Fieldobjects, specifying the inputs and outputs to some model. We don’t make a distinction between inputs and outputs here, though - all operations are done on all fields, and when we return arrays, we return them as dictionaries keyed by field name. A model can then decide which fields it wants to use as inputs as which as outputs.
Instancecan start out either indexed or un-indexed. During the data processing pipeline, all fields will end up as
IndexedFields, and will then be converted into padded arrays by a
Fieldobjects that will be used to produce data arrays for this instance.
as_array_dict(padding_lengths: typing.Dict[str, typing.Dict[str, int]] = None) → typing.Dict[str, DataArray]¶
Fieldin this instance to the lengths given in
padding_lengths(which is keyed by field name, then by padding key, the same as the return value in
get_padding_lengths()), returning a list of numpy arrays for each field.
padding_lengthsis omitted, we will call
self.get_padding_lengths()to get the sizes of the arrays to create.
count_vocab_items(counter: typing.Dict[str, typing.Dict[str, int]])¶
Increments counts in the given
counterfor all of the vocabulary items in all of the
get_padding_lengths() → typing.Dict[str, typing.Dict[str, int]]¶
Returns a dictionary of padding lengths, keyed by field name. Each
Fieldreturns a mapping from padding keys to actual lengths, and we just key that dictionary by field name.
IndexedFields, given the
Vocabulary. This mutates the current object, it does not return a new