tf_agents.utils.numpy_storage.NumpyStorage
Stay organized with collections
Save and categorize content based on your preferences.
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
View source
get(
idx
)
Get value stored at idx.
set
View source
set(
table_idx, value
)
Set table_idx to value.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-04-26 UTC.
[null,null,["Last updated 2024-04-26 UTC."],[],[],null,["# tf_agents.utils.numpy_storage.NumpyStorage\n\n\u003cbr /\u003e\n\n|-----------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/tensorflow/agents/blob/v0.19.0/tf_agents/utils/numpy_storage.py#L176-L242) |\n\nA class to store nested objects in a collection of numpy arrays. \n\n tf_agents.utils.numpy_storage.NumpyStorage(\n data_spec, capacity\n )\n\nIf a data_spec of `{'foo': ArraySpec(shape=(4,), dtype=np.uint8), 'bar':\nArraySpec(shape=(3, 7), dtype=np.float32)}` were used, then this would create\ntwo arrays, one for the 'foo' key and one for the 'bar' key. The .get and\n.set methods would return/take Python dictionaries, but break down the\ncomponent arrays before storing them.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|-------------|------------------------------------------------------------------------------------------------------------|\n| `data_spec` | An ArraySpec or a list/tuple/nest of ArraySpecs describing a single item that can be stored in this table. |\n| `capacity` | The maximum number of items that can be stored in the buffer. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Raises ------ ||\n|--------------|--------------------------------------------------------|\n| `ValueError` | If data_spec is not an instance or nest of ArraySpecs. |\n\n\u003cbr /\u003e\n\nMethods\n-------\n\n### `get`\n\n[View source](https://github.com/tensorflow/agents/blob/v0.19.0/tf_agents/utils/numpy_storage.py#L232-L237) \n\n get(\n idx\n )\n\nGet value stored at idx.\n\n### `set`\n\n[View source](https://github.com/tensorflow/agents/blob/v0.19.0/tf_agents/utils/numpy_storage.py#L239-L242) \n\n set(\n table_idx, value\n )\n\nSet table_idx to value."]]