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.

make_features(element=None, features=None, training=None)[source]

Converts words to characters.

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
Returns

The model input.

visualize(model_root, log_dir)[source]

Visualizes the transformation, usually embeddings.

Parameters
  • model_root – The root model object.

  • log_dir – The active log directory.