![]() |
An ArraySpec
that specifies minimum and maximum values.
Inherits From: ArraySpec
tf_agents.specs.BoundedArraySpec(
shape, dtype, minimum=None, maximum=None, name=None
)
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)
Args | |
---|---|
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 .
|
Raises | |
---|---|
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.
|
Attributes | |
---|---|
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
check_array(
array
)
Return true if the given array conforms to the spec.
from_array
@staticmethod
from_array( array, name=None )
Construct a spec from the given array or number.
from_spec
@classmethod
from_spec( spec, name=None )
Construct a spec from the given spec.
replace
replace(
shape=None, dtype=None, minimum=None, maximum=None, name=None
)
__eq__
__eq__(
other
)
Checks if the shape and dtype of two specs are equal.
__ne__
__ne__(
other
)
Return self!=value.