CharEmbedder
- class opennmt.inputters.CharEmbedder(*args, **kwargs)[source]
Base class for character-aware inputters.
Inherits from:
opennmt.inputters.TextInputter
Extended by:
- __init__(embedding_size, dropout=0.0, **kwargs)[source]
Initializes the parameters of the character embedder.
- Parameters
embedding_size – The size of the character embedding.
dropout – The probability to drop units in the embedding.
**kwargs – Additional layer keyword arguments.
- build(input_shape)[source]
Creates the variables of the layer (for subclass implementers).
This is a method that implementers of subclasses of Layer or Model can override if they need a state-creation step in-between layer instantiation and layer call. It is invoked automatically before the first execution of call().
This is typically used to create the weights of Layer subclasses (at the discretion of the subclass implementer).
- Parameters
input_shape – Instance of TensorShape, or list of instances of TensorShape if the layer expects a list of inputs (one instance per input).
- abstract call(features, training=None)[source]
Creates the model input from the features (e.g. word embeddings).
- Parameters
features – A dictionary of
tf.Tensor
, the output ofopennmt.inputters.Inputter.make_features()
.training – Run in training mode.
- Returns
The model input.