BoundedTensorSpec
Inherits From: TensorSpec
Defined in tensorflow/python/framework/tensor_spec.py.
A TensorSpec that specifies minimum and maximum values.
Example usage:
spec = tensor_spec.BoundedTensorSpec((1, 2, 3), tf.float32, 0, (5, 5, 5)) tf_minimum = tf.convert_to_tensor(spec.minimum, dtype=spec.dtype) tf_maximum = tf.convert_to_tensor(spec.maximum, dtype=spec.dtype)
Bounds are meant to be inclusive. This is especially important for integer types. The following spec will be satisfied by tensors with values in the set {0, 1, 2}:
spec = tensor_spec.BoundedTensorSpec((3, 5), tf.int32, 0, 2)
dtypeReturns the dtype of elements in the tensor.
is_continuousWhether spec is continuous.
is_discreteWhether spec is discrete.
maximumReturns a NumPy array specifying the maximum bounds (inclusive).
minimumReturns a NumPy array specifying the minimum bounds (inclusive).
nameReturns the name of the described tensor.
shapeReturns the TensorShape that represents the shape of the tensor.
__init____init__(
shape,
dtype,
minimum,
maximum,
name=None
)
Initializes a new BoundedTensorSpec.
shape: Value convertible to tf.TensorShape. The shape of the tensor.dtype: Value convertible to tf.DType. The type of the tensor values.minimum: Number or sequence specifying the minimum 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 provided or not broadcastable to shape.TypeError: If the shape is not an iterable or if the dtype is an invalid numpy dtype.__eq____eq__(other)
Return self==value.
__ne____ne__(other)
Return self!=value.
__reduce____reduce__()
helper for pickle
from_spec@classmethod
from_spec(
cls,
spec
)
from_tensorfrom_tensor(
cls,
tensor,
name=None
)
is_bounded@classmethod is_bounded(cls)
is_compatible_withis_compatible_with(spec_or_tensor)
True if the shape and dtype of spec_or_tensor are compatible.
© 2018 The TensorFlow Authors. All rights reserved.
Licensed under the Creative Commons Attribution License 3.0.
Code samples licensed under the Apache 2.0 License.
https://www.tensorflow.org/api_docs/python/tf/contrib/framework/BoundedTensorSpec