tf_agents.agents.ddpg.critic_rnn_network.CriticRnnNetwork

Creates a recurrent Critic network.

Inherits From: Network

input_tensor_spec A tuple of (observation, action) each of type tensor_spec.TensorSpec representing the inputs.
observation_conv_layer_params Optional list of convolution layers parameters to apply to the observations, where each item is a length-three tuple indicating (filters, kernel_size, stride).
observation_fc_layer_params Optional list of fully_connected parameters, where each item is the number of units in the layer. This is applied after the observation convultional layer.
action_fc_layer_params Optional list of parameters for a fully_connected layer to apply to the actions, where each item is the number of units in the layer.
joint_fc_layer_params Optional list of parameters for a fully_connected layer to apply after merging observations and actions, where each item is the number of units in the layer.
lstm_size An iterable of ints specifying the LSTM cell sizes to use.
output_fc_layer_params Optional list of fully_connected parameters, where each item is the number of units in the layer. This is applied after the LSTM cell.
activation_fn Activation function, e.g. tf.nn.relu, slim.leaky_relu, ...
kernel_initializer kernel initializer for all layers except for the value regression layer. If None, a VarianceScaling initializer will be used.
last_kernel_initializer kernel initializer for the value regression layer . If None, a RandomUniform initializer will be used.
rnn_construction_fn (Optional.) Alternate RNN construction function, e.g. tf.keras.layers.LSTM, tf.keras.layers.CuDNNLSTM. It is invalid to provide both rnn_construction_fn and lstm_size.
rnn_construction_kwargs (Optional.) Dictionary or arguments to pass to rnn_construction_fn. The RNN will be constructed via: rnn_layer = rnn_construction_fn(**rnn_construction_kwargs)
name A string representing name of the network.

ValueError If observation_spec or action_spec contains more than one item.
ValueError If neither lstm_size nor rnn_construction_fn are provided.
ValueError If both lstm_size and rnn_construction_fn are provided.

input_tensor_spec Returns the spec of the input to the network of type InputSpec.
layers Get the list of all (nested) sub-layers used in this Network.
state_spec

Methods

copy

View source

Create a shallow copy of this network.

Args
**kwargs Args to override when recreating this network. Commonly overridden args include 'name'.

Returns
A shallow copy of this network.

create_variables

View source

Force creation of the network's variables.

Return output specs.

Args
input_tensor_spec (Optional). Override or provide an input tensor spec when creating variables.
**kwargs Other arguments to network.call(), e.g. training=True.

Returns
Output specs - a nested spec calculated from the outputs (excluding any batch dimensions). If any of the output elements is a tfp Distribution, the associated spec entry returned is a DistributionSpec.

Raises
ValueError If no input_tensor_spec is provided, and the network did not provide one during construction.

get_initial_state

View source

Returns an initial state usable by the network.

Args
batch_size Tensor or constant: size of the batch dimension. Can be None in which case not dimensions gets added.

Returns
A nested object of type self.state_spec containing properly initialized Tensors.

get_layer

View source

Retrieves a layer based on either its name (unique) or index.

If name and index are both provided, index will take precedence. Indices are based on order of horizontal graph traversal (bottom-up).

Args
name String, name of layer.
index Integer, index of layer.

Returns
A layer instance.

Raises
ValueError In case of invalid layer name or index.

summary

View source

Prints a string summary of the network.

Args
line_length Total length of printed lines (e.g. set this to adapt the display to different terminal window sizes).
positions Relative or absolute positions of log elements in each line. If not provided, defaults to [.33, .55, .67, 1.].
print_fn Print function to use. Defaults to print. It will be called on each line of the summary. You can set it to a custom function in order to capture the string summary.

Raises
ValueError if summary() is called before the model is built.