View source on GitHub |
A class to store nested objects in a collection of numpy arrays.
tf_agents.utils.numpy_storage.NumpyStorage(
data_spec, capacity
)
If a data_spec of {'foo': ArraySpec(shape=(4,), dtype=np.uint8), 'bar':
ArraySpec(shape=(3, 7), dtype=np.float32)}
were used, then this would create
two arrays, one for the 'foo' key and one for the 'bar' key. The .get and
.set methods would return/take Python dictionaries, but break down the
component arrays before storing them.
Args | |
---|---|
data_spec
|
An ArraySpec or a list/tuple/nest of ArraySpecs describing a single item that can be stored in this table. |
capacity
|
The maximum number of items that can be stored in the buffer. |
Raises | |
---|---|
ValueError
|
If data_spec is not an instance or nest of ArraySpecs. |
Methods
get
get(
idx
)
Get value stored at idx.
set
set(
table_idx, value
)
Set table_idx to value.