LayerWrapper

class opennmt.layers.LayerWrapper(*args, **kwargs)[source]

Layer wrapper for input/output normalization, input/output dropout and residual connection.

Inherits from: keras.src.engine.base_layer.Layer

Extended by:

__init__(layer, normalize_input=False, normalize_output=False, input_dropout=0, output_dropout=0, residual_connection=False, **kwargs)[source]

Initializes the layer.

Parameters
  • layer – The layer to wrap.

  • normalize_input – Apply layer normalization on the input.

  • normalize_output – Apply layer normalization on the output.

  • input_dropout – The probability to drop units in the layer input.

  • output_dropout – The probability to drop units in the layer output.

  • residual_connection – Add the inputs to layer outputs (if their shape are compatible).

  • kwargs – Additional layer arguments.

call(inputs, *args, **kwargs)[source]

Runs the wrapper.

get_config()[source]

Returns the layer wrapper configuration.

classmethod from_config(config)[source]

Creates a layer wrapper from its configuration.