tf_agents.specs.ArraySpec

View source on GitHub

Describes a numpy array or scalar shape and dtype.

An ArraySpec allows an API to describe the arrays that it accepts or returns, before that array exists. The equivalent version describing a tf.Tensor is TensorSpec.

shape An iterable specifying the array shape.
dtype numpy dtype or string specifying the array dtype.
name Optional string containing a semantic name for the corresponding array. Defaults to None.

TypeError If the shape is not an iterable or if the dtype is an invalid numpy dtype.

dtype Returns a numpy dtype specifying the array dtype.
name Returns the name of the ArraySpec.
shape Returns a tuple specifying the array shape.

Methods

check_array

View source

Return whether the given NumPy array conforms to the spec.

Args
array A NumPy array or a scalar. Tuples and lists will not be converted to a NumPy array automatically; they will cause this function to return false, even if a conversion to a conforming array is trivial.

Returns
True if the array conforms to the spec, False otherwise.

from_array

View source

Construct a spec from the given array or number.

from_spec

View source

Construct a spec from the given spec.

__eq__

View source

Checks if the shape and dtype of two specs are equal.

__ne__

View source

Return self!=value.