View source on GitHub
|
Represents the type of the elements in a Tensor.
Inherits From: TraceType
tf.dtypes.DType(
type_enum, handle_data=None
)
DType's are used to specify the output data type for operations which
require it, or to inspect the data type of existing Tensor's.
Examples:
tf.constant(1, dtype=tf.int64)<tf.Tensor: shape=(), dtype=int64, numpy=1>tf.constant(1.0).dtypetf.float32
See tf.dtypes for a complete list of DType's defined.
Attributes |
|---|
as_datatype_enum
types_pb2.DataType enum value based on this data type.
as_numpy_dtype
type object based on this DType.
base_dtype
DType based on this DType.
is_bool
is_complex
is_floating
is_integer
is_numpy_compatible
is_quantized
is_unsigned
Non-numeric, unordered, and quantized types are not considered unsigned, and
this function returns False.
limits
(min, max) tuple, of the dtype. Args: clip_negative : bool, optional If True, clip the negative range (i.e. return 0 for min intensity) even if the image dtype allows negative values. Returns min, max : tuple Lower and upper intensity limits.
max
min
name
real_dtype
DType corresponding to this DType's real part.
size
Methods
experimental_as_proto
experimental_as_proto() -> types_pb2.SerializedDType
Returns a proto representation of the Dtype instance.
experimental_from_proto
@classmethodexperimental_from_proto( proto: types_pb2.SerializedDType ) -> 'DType'
Returns a Dtype instance based on the serialized proto.
experimental_type_proto
@classmethodexperimental_type_proto() -> Type[types_pb2.SerializedDType]
Returns the type of proto associated with DType serialization.
is_compatible_with
is_compatible_with(
other
)
Returns True if the other DType will be converted to this DType.
The conversion rules are as follows:
DType(T) .is_compatible_with(DType(T)) == True
| Args |
|---|
other
DType (or object that may be converted to a DType).
| Returns | |
|---|---|
True if a Tensor of the other DType will be implicitly converted to
this DType.
|
is_subtype_of
is_subtype_of(
other: tf.types.experimental.TraceType
) -> bool
See tf.types.experimental.TraceType base class.
most_specific_common_supertype
most_specific_common_supertype(
types: Sequence[tf.types.experimental.TraceType]
) -> Optional['DType']
See tf.types.experimental.TraceType base class.
__eq__
__eq__(
other
)
Returns True iff this DType refers to the same type as other.
__ne__
__ne__(
other
)
Returns True iff self != other.
View source on GitHub