|View source on GitHub|
A table that can store Tensors or nested Tensors.
tf_agents.replay_buffers.table.Table( tensor_spec, capacity, scope='Table' )
tensor_spec: A nest of TensorSpec representing each value that can be stored in the table.
capacity: Maximum number of values the table can store.
scope: Variable scope for the Table.
name: Returns the name of this module as passed or determined in the ctor.
NOTE: This is not the same as the
self.name_scope.namewhich includes parent module names.
name_scope: Returns a
tf.name_scopeinstance for this class.
submodules: Sequence of all sub-modules.
Submodules are modules which are properties of this module, or found as properties of modules which are properties of this module (and so on).
a = tf.Module() b = tf.Module() c = tf.Module() a.b = b b.c = c assert list(a.submodules) == [b, c] assert list(b.submodules) == [c] assert list(c.submodules) == 
trainable_variables: Sequence of trainable variables owned by this module and its submodules.
ValueError: If the names in tensor_spec are empty or not unique.
read( rows, slots=None )
Returns values for the given rows.
rows: A scalar/list/tensor of location(s) to read values from. If rows is a scalar, a single value is returned without a batch dimension. If rows is a list of integers or a rank-1 int Tensor a batch of values will be returned with each Tensor having an extra first dimension equal to the length of rows.
slots: Optional list/tuple/nest of slots to read from. If None, all tensors at the given rows are retrieved and the return value has the same structure as the tensor_spec. Otherwise, only tensors with names matching the slots are retrieved, and the return value has the same structure as slots.
Values at given rows.
Sequence of variables owned by this module and its submodules.
A sequence of variables for the current module (sorted by attribute name) followed by variables from all submodules recursively (breadth first).
@classmethod with_name_scope( cls, method )
Decorator to automatically enter the module name scope.
class MyModule(tf.Module): @tf.Module.with_name_scope def __call__(self, x): if not hasattr(self, 'w'): self.w = tf.Variable(tf.random.normal([x.shape, 64])) return tf.matmul(x, self.w)
mod = MyModule() mod(tf.ones([8, 32])) # ==> <tf.Tensor: ...> mod.w # ==> <tf.Variable ...'my_module/w:0'>
method: The method to wrap.
The original method wrapped such that it enters the module's name scope.
write( rows, values, slots=None )
Returns ops for writing values at the given rows.
rows: A scalar/list/tensor of location(s) to write values at.
values: A nest of Tensors to write. If rows has more than one element, values can have an extra first dimension representing the batch size. Values must have the same structure as the tensor_spec of this class if
slotsis None, otherwise it must have the same structure as
slots: Optional list/tuple/nest of slots to write. If None, all tensors in the table are updated. Otherwise, only tensors with names matching the slots are updated.
Ops for writing values at rows.