tf2rl.networks package

Submodules

tf2rl.networks.atari_model module

class tf2rl.networks.atari_model.AtariBaseModel(*args, **kwargs)

Bases: tensorflow.python.keras.engine.training.Model

__init__(name, enable_noisy_dqn=False)
call(inputs)

Calls the model on new inputs.

In this case call just reapplies all ops in the graph to the new inputs (e.g. build a new computational graph from the provided inputs).

Parameters
  • inputs – A tensor or list of tensors.

  • training – Boolean or boolean scalar tensor, indicating whether to run the Network in training mode or inference mode.

  • mask – A mask or list of masks. A mask can be either a tensor or None (no mask).

Returns

A tensor if there is a single output, or a list of tensors if there are more than one outputs.

class tf2rl.networks.atari_model.AtariQFunc(*args, **kwargs)

Bases: tf2rl.networks.atari_model.AtariBaseModel

__init__(state_shape, action_dim, units=None, name='QFunc', enable_dueling_dqn=False, enable_noisy_dqn=False, enable_categorical_dqn=False, n_atoms=51)
call(inputs)

Calls the model on new inputs.

In this case call just reapplies all ops in the graph to the new inputs (e.g. build a new computational graph from the provided inputs).

Parameters
  • inputs – A tensor or list of tensors.

  • training – Boolean or boolean scalar tensor, indicating whether to run the Network in training mode or inference mode.

  • mask – A mask or list of masks. A mask can be either a tensor or None (no mask).

Returns

A tensor if there is a single output, or a list of tensors if there are more than one outputs.

class tf2rl.networks.atari_model.AtariCategoricalActor(*args, **kwargs)

Bases: tf2rl.policies.tfp_categorical_actor.CategoricalActor, tf2rl.networks.atari_model.AtariBaseModel

__init__(state_shape, action_dim, units=None, name='AtariCategoricalActor')
class tf2rl.networks.atari_model.AtariCategoricalActorCritic(*args, **kwargs)

Bases: tf2rl.policies.tfp_categorical_actor.CategoricalActorCritic, tf2rl.networks.atari_model.AtariBaseModel

__init__(state_shape, action_dim, units=None, name='AtariCategoricalActorCritic')

tf2rl.networks.dmc_model module

class tf2rl.networks.dmc_model.Encoder(*args, **kwargs)

Bases: tensorflow.python.keras.engine.training.Model

__init__(obs_shape=(84, 84, 9), feature_dim=50, n_conv_layers=4, n_conv_filters=32, name='curl_encoder')
call(inputs, stop_q_grad=False)

Calls the model on new inputs.

In this case call just reapplies all ops in the graph to the new inputs (e.g. build a new computational graph from the provided inputs).

Parameters
  • inputs – A tensor or list of tensors.

  • training – Boolean or boolean scalar tensor, indicating whether to run the Network in training mode or inference mode.

  • mask – A mask or list of masks. A mask can be either a tensor or None (no mask).

Returns

A tensor if there is a single output, or a list of tensors if there are more than one outputs.

class tf2rl.networks.dmc_model.Decoder(*args, **kwargs)

Bases: tensorflow.python.keras.engine.training.Model

__init__(last_conv_dim=35, n_deconv_layers=4, n_deconv_filters=32, n_output_channel=9, name='curl_decoder')
call(inputs)

Calls the model on new inputs.

In this case call just reapplies all ops in the graph to the new inputs (e.g. build a new computational graph from the provided inputs).

Parameters
  • inputs – A tensor or list of tensors.

  • training – Boolean or boolean scalar tensor, indicating whether to run the Network in training mode or inference mode.

  • mask – A mask or list of masks. A mask can be either a tensor or None (no mask).

Returns

A tensor if there is a single output, or a list of tensors if there are more than one outputs.

tf2rl.networks.noisy_dense module

class tf2rl.networks.noisy_dense.NoisyDense(*args, **kwargs)

Bases: tensorflow.python.keras.engine.base_layer.Layer

__init__(units, sigma_init=0.017, activation=None, use_bias=True, kernel_initializer='glorot_uniform', bias_initializer='zeros', kernel_regularizer=None, bias_regularizer=None, activity_regularizer=None, kernel_constraint=None, bias_constraint=None, trainable=True, **kwargs)
build(input_shape)

Creates the variables of the layer (optional, 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.

This is typically used to create the weights of Layer subclasses.

Parameters

input_shape – Instance of TensorShape, or list of instances of TensorShape if the layer expects a list of inputs (one instance per input).

call(inputs)

This is where the layer’s logic lives.

Note here that call() method in tf.keras is little bit different from keras API. In keras API, you can pass support masking for layers as additional arguments. Whereas tf.keras has compute_mask() method to support masking.

Parameters
  • inputs – Input tensor, or list/tuple of input tensors.

  • **kwargs – Additional keyword arguments. Currently unused.

Returns

A tensor or list/tuple of tensors.

compute_output_shape(input_shape)

Computes the output shape of the layer.

If the layer has not been built, this method will call build on the layer. This assumes that the layer will later be used with inputs that match the input shape provided here.

Parameters

input_shape – Shape tuple (tuple of integers) or list of shape tuples (one per output tensor of the layer). Shape tuples can include None for free dimensions, instead of an integer.

Returns

An input shape tuple.

tf2rl.networks.spectral_norm_dense module

class tf2rl.networks.spectral_norm_dense.SNDense(*args, **kwargs)

Bases: tensorflow.python.keras.layers.core.Dense

__init__(units, trainable=True, u_kernel_initializer=<class 'tensorflow.python.keras.initializers.initializers_v2.TruncatedNormal'>, **kwargs)
build(input_shape)

Creates the variables of the layer (optional, 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.

This is typically used to create the weights of Layer subclasses.

Parameters

input_shape – Instance of TensorShape, or list of instances of TensorShape if the layer expects a list of inputs (one instance per input).

compute_spectral_norm()
call(inputs)

This is where the layer’s logic lives.

Note here that call() method in tf.keras is little bit different from keras API. In keras API, you can pass support masking for layers as additional arguments. Whereas tf.keras has compute_mask() method to support masking.

Parameters
  • inputs – Input tensor, or list/tuple of input tensors.

  • **kwargs – Additional keyword arguments. Currently unused.

Returns

A tensor or list/tuple of tensors.

get_config()

Returns the config of the layer.

A layer config is a Python dictionary (serializable) containing the configuration of a layer. The same layer can be reinstantiated later (without its trained weights) from this configuration.

The config of a layer does not include connectivity information, nor the layer class name. These are handled by Network (one layer of abstraction above).

Returns

Python dictionary.

Module contents