# tf_agents.specs.ArraySpec

<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/agents/blob/v0.19.0/tf_agents/specs/array_spec.py#L169-L267) |

Describes a numpy array or scalar shape and dtype.

#### View aliases


**Main aliases**

[`tf_agents.specs.array_spec.ArraySpec`](https://www.tensorflow.org/agents/api_docs/python/tf_agents/specs/ArraySpec)

<br />

    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`](https://www.tensorflow.org/api_docs/python/tf/Tensor) is `TensorSpec`.

<br />

<br />

<br />

| ## 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`. |

<br />

<br />

<br />

<br />

| ## Raises ||
|---|---|
| `TypeError` | If the shape is not an iterable or if the `dtype` is an invalid numpy dtype. |

<br />

<br />

<br />

<br />

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

<br />

## Methods

### `check_array`

[View source](https://github.com/tensorflow/agents/blob/v0.19.0/tf_agents/specs/array_spec.py#L227-L243)

    check_array(
        array
    )

Return whether the given NumPy array conforms to the spec.

<br />

<br />

<br />

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

<br />

<br />

<br />

<br />

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

<br />

### `from_array`

[View source](https://github.com/tensorflow/agents/blob/v0.19.0/tf_agents/specs/array_spec.py#L248-L256)

    @staticmethod
    from_array(
        array, name=None
    )

Construct a spec from the given array or number.

### `from_spec`

[View source](https://github.com/tensorflow/agents/blob/v0.19.0/tf_agents/specs/array_spec.py#L258-L261)

    @staticmethod
    from_spec(
        spec
    )

Construct a spec from the given spec.

### `replace`

[View source](https://github.com/tensorflow/agents/blob/v0.19.0/tf_agents/specs/array_spec.py#L263-L267)

    replace(
        shape=None, dtype=None, name=None
    )

### `__eq__`

[View source](https://github.com/tensorflow/agents/blob/v0.19.0/tf_agents/specs/array_spec.py#L218-L222)

    __eq__(
        other
    )

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

### `__ne__`

[View source](https://github.com/tensorflow/agents/blob/v0.19.0/tf_agents/specs/array_spec.py#L224-L225)

    __ne__(
        other
    )

Return self!=value.