View source on GitHub |
Describes a numpy array or scalar shape and dtype.
tf_agents.specs.ArraySpec(
shape, dtype, name=None
)
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
.
Raises | |
---|---|
TypeError
|
If the shape is not an iterable or if the dtype is an invalid
numpy dtype.
|
Attributes | |
---|---|
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
check_array(
array
)
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
@staticmethod
from_array( array, name=None )
Construct a spec from the given array or number.
from_spec
@staticmethod
from_spec( spec )
Construct a spec from the given spec.
replace
replace(
shape=None, dtype=None, name=None
)
__eq__
__eq__(
other
)
Checks if the shape and dtype of two specs are equal.
__ne__
__ne__(
other
)
Return self!=value.