metarl.np.embeddings.encoder module

Base class for context encoder.

class Encoder[source]

Bases: abc.ABC

Base class of context encoders for training meta-RL algorithms.

get_latent(input_value)[source]

Encode an input value.

Parameters:input_value (numpy.ndarray) – Input value of (input_dim, ) shape.
Returns:Encoded embedding.
Return type:numpy.ndarray
get_latents(input_values)[source]

Encode a batch of input values.

Parameters:input_values (numpy.ndarray) – Input values of (N, input_dim) shape.
Returns:Encoded embeddings.
Return type:numpy.ndarray
input_dim

Dimension of the encoder input.

Type:int
output_dim

Dimension of the encoder output (embedding).

Type:int
reset(do_resets=None)[source]

Reset the encoder.

This is effective only to recurrent encoder. do_resets is effective only to vectoried encoder.

For a vectorized encoder, do_resets is an array of boolean indicating which internal states to be reset. The length of do_resets should be equal to the length of inputs.

Parameters:do_resets (numpy.ndarray) – Bool array indicating which states to be reset.
spec

Input and output space.

Type:metarl.InOutSpec
class StochasticEncoder[source]

Bases: metarl.np.embeddings.encoder.Encoder

An stochastic context encoders.

An stochastic encoder maps an input to a distribution, but not a deterministic vector.

distribution

Embedding distribution.

Type:object