Missed TensorFlow Dev Summit? Check out the video playlist. Watch recordings

tf_agents.specs.ArraySpec

View source on GitHub

Describes a numpy array or scalar shape and dtype.

tf_agents.specs.ArraySpec(
    *args, **kwargs
)

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.

Args:

  • 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.

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.

Raises:

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

Methods

__eq__

View source

__eq__(
    other
)

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

__ne__

View source

__ne__(
    other
)

Return self!=value.

check_array

View source

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

View source

@staticmethod
from_array(
    array, name=None
)

Construct a spec from the given array or number.

from_spec

View source

@staticmethod
from_spec(
    spec
)

Construct a spec from the given spec.