تاریخ را ذخیره کنید! Google I / O 18-20 مه بازمی گردد

# tf_agents.specs.BoundedArraySpec

An `ArraySpec` that specifies minimum and maximum values.

Inherits From: `ArraySpec`

### Used in the notebooks

Used in the tutorials

#### Example usage:

``````# Specifying the same minimum and maximum for every element.
spec = BoundedArraySpec((3, 4), np.float64, minimum=0.0, maximum=1.0)

# Specifying a different minimum and maximum for each element.
spec = BoundedArraySpec(
(2,), np.float64, minimum=[0.1, 0.2], maximum=[0.9, 0.9])

# Specifying the same minimum and a different maximum for each element.
spec = BoundedArraySpec(
(3,), np.float64, minimum=-10.0, maximum=[4.0, 5.0, 3.0])
``````

Bounds are meant to be inclusive. This is especially important for integer types. The following spec will be satisfied by arrays with values in the set {0, 1, 2}:

``````spec = BoundedArraySpec((3, 4), np.int, minimum=0, maximum=2)
``````

`shape` An iterable specifying the array shape.
`dtype` numpy dtype or string specifying the array dtype.
`minimum` Number or sequence specifying the maximum element bounds (inclusive). Must be broadcastable to `shape`.
`maximum` Number or sequence specifying the maximum element bounds (inclusive). Must be broadcastable to `shape`.
`name` Optional string containing a semantic name for the corresponding array. Defaults to `None`.

`ValueError` If `minimum` or `maximum` are not broadcastable to `shape` or if the limits are outside of the range of the specified dtype.
`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.
`maximum` Returns a NumPy array specifying the maximum bounds (inclusive).
`minimum` Returns a NumPy array specifying the minimum bounds (inclusive).
`name` Returns the name of the ArraySpec.
`num_values` Returns the number of values for discrete BoundedArraySpec.
`shape` Returns a `tuple` specifying the array shape.

## Methods

### `check_array`

View source

Return true if the given array conforms to the spec.

### `from_array`

View source

Construct a spec from the given array or number.

### `from_spec`

View source

Construct a spec from the given spec.

View source

### `__eq__`

View source

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

### `__ne__`

View source

Return self!=value.