garage.tf.embeddings.encoder module

Encoders in TensorFlow.

class Encoder(name)[source]

Bases: garage.np.embeddings.encoder.Encoder, garage.tf.models.module.Module

Base class for encoders in TensorFlow.

clone(name)[source]

Return a clone of the encoder.

It only copies the configuration of the primitive, not the parameters.

Parameters:name (str) – Name of the newly created encoder. It has to be different from source encoder if cloned under the same computational graph.
Returns:Newly cloned encoder.
Return type:garage.tf.embeddings.encoder.Encoder
get_latent(input_value)[source]

Get a sample of embedding for the given input.

Parameters:input_value (numpy.ndarray) – Tensor to encode.
Returns:An embedding sampled from embedding distribution. dict: Embedding distribution information.
Return type:numpy.ndarray

Note

It returns an embedding and a dict, with keys - mean (numpy.ndarray): Mean of the distribution. - log_std (numpy.ndarray): Log standard deviation of the

distribution.
get_latents(input_values)[source]

Get samples of embedding for the given inputs.

Parameters:input_values (numpy.ndarray) – Tensors to encode.
Returns:Embeddings sampled from embedding distribution. dict: Embedding distribution information.
Return type:numpy.ndarray

Note

It returns an embedding and a dict, with keys - mean (list[numpy.ndarray]): Means of the distribution. - log_std (list[numpy.ndarray]): Log standard deviations of the

distribution.
class StochasticEncoder(name)[source]

Bases: garage.np.embeddings.encoder.StochasticEncoder, garage.tf.models.module.StochasticModule

Base class for stochastic encoders in TensorFlow.

build(embedding_input, name=None)[source]

Build encoder.

After buil, self.distribution is a Gaussian distribution conitioned on embedding_input.

Parameters:
  • embedding_input (tf.Tensor) – Embedding input.
  • name (str) – Name of the model, which is also the name scope.