tf.dtypes.DType
Stay organized with collections
Save and categorize content based on your preferences.
Represents the type of the elements in a Tensor
.
tf.dtypes.DType(
type_enum
)
The following DType
objects are defined:
The tf.as_dtype()
function converts numpy types and string type
names to a DType
object.
Args |
type_enum
|
A types_pb2.DataType enum value.
|
Raises |
TypeError
|
If type_enum is not a value types_pb2.DataType .
|
Attributes |
as_datatype_enum
|
Returns a types_pb2.DataType enum value based on this DType .
|
as_numpy_dtype
|
Returns a numpy.dtype based on this DType .
|
base_dtype
|
Returns a non-reference DType based on this DType .
|
is_bool
|
Returns whether this is a boolean data type
|
is_complex
|
Returns whether this is a complex floating point type.
|
is_floating
|
Returns whether this is a (non-quantized, real) floating point type.
|
is_integer
|
Returns whether this is a (non-quantized) integer type.
|
is_numpy_compatible
|
|
is_quantized
|
Returns whether this is a quantized data type.
|
is_unsigned
|
Returns whether this type is unsigned.
Non-numeric, unordered, and quantized types are not considered unsigned, and
this function returns False .
|
limits
|
Return intensity limits, i.e.
(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
|
Returns the maximum representable value in this data type.
|
min
|
Returns the minimum representable value in this data type.
|
name
|
Returns the string name for this DType .
|
real_dtype
|
Returns the dtype correspond to this dtype's real part.
|
size
|
|
Methods
is_compatible_with
View source
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
|
A 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 .
|
__eq__
View source
__eq__(
other
)
Returns True iff this DType refers to the same type as other
.
__ne__
View source
__ne__(
other
)
Returns True iff self != other.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2020-10-01 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2020-10-01 UTC."],[],[],null,["# tf.dtypes.DType\n\n\u003cbr /\u003e\n\n|-------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------|\n| [TensorFlow 1 version](/versions/r1.15/api_docs/python/tf/dtypes/DType) | [View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v2.0.0/tensorflow/python/framework/dtypes.py#L31-L296) |\n\nRepresents the type of the elements in a `Tensor`.\n\n#### View aliases\n\n\n**Main aliases**\n\n[`tf.DType`](/api_docs/python/tf/dtypes/DType)\n**Compat aliases for migration**\n\nSee\n[Migration guide](https://www.tensorflow.org/guide/migrate) for\nmore details.\n\n[`tf.compat.v1.DType`](/api_docs/python/tf/dtypes/DType), [`tf.compat.v1.dtypes.DType`](/api_docs/python/tf/dtypes/DType)\n\n\u003cbr /\u003e\n\n tf.dtypes.DType(\n type_enum\n )\n\nThe following `DType` objects are defined:\n\n- [`tf.float16`](../../tf#float16): 16-bit half-precision floating-point.\n- [`tf.float32`](../../tf#float32): 32-bit single-precision floating-point.\n- [`tf.float64`](../../tf#float64): 64-bit double-precision floating-point.\n- [`tf.bfloat16`](../../tf#bfloat16): 16-bit truncated floating-point.\n- [`tf.complex64`](../../tf#complex64): 64-bit single-precision complex.\n- [`tf.complex128`](../../tf#complex128): 128-bit double-precision complex.\n- [`tf.int8`](../../tf#int8): 8-bit signed integer.\n- [`tf.uint8`](../../tf#uint8): 8-bit unsigned integer.\n- [`tf.uint16`](../../tf#uint16): 16-bit unsigned integer.\n- [`tf.uint32`](../../tf#uint32): 32-bit unsigned integer.\n- [`tf.uint64`](../../tf#uint64): 64-bit unsigned integer.\n- [`tf.int16`](../../tf#int16): 16-bit signed integer.\n- [`tf.int32`](../../tf#int32): 32-bit signed integer.\n- [`tf.int64`](../../tf#int64): 64-bit signed integer.\n- [`tf.bool`](../../tf#bool): Boolean.\n- [`tf.string`](../../tf#string): String.\n- [`tf.qint8`](../../tf#qint8): Quantized 8-bit signed integer.\n- [`tf.quint8`](../../tf#quint8): Quantized 8-bit unsigned integer.\n- [`tf.qint16`](../../tf#qint16): Quantized 16-bit signed integer.\n- [`tf.quint16`](../../tf#quint16): Quantized 16-bit unsigned integer.\n- [`tf.qint32`](../../tf#qint32): Quantized 32-bit signed integer.\n- [`tf.resource`](../../tf#resource): Handle to a mutable resource.\n- [`tf.variant`](../../tf#variant): Values of arbitrary types.\n\nThe [`tf.as_dtype()`](../../tf/dtypes/as_dtype) function converts numpy types and string type\nnames to a `DType` object.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|-------------|------------------------------------|\n| `type_enum` | A `types_pb2.DataType` enum value. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Raises ------ ||\n|-------------|-----------------------------------------------------|\n| `TypeError` | If `type_enum` is not a value `types_pb2.DataType`. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Attributes ---------- ||\n|-----------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `as_datatype_enum` | Returns a `types_pb2.DataType` enum value based on this `DType`. |\n| `as_numpy_dtype` | Returns a `numpy.dtype` based on this `DType`. |\n| `base_dtype` | Returns a non-reference `DType` based on this `DType`. |\n| `is_bool` | Returns whether this is a boolean data type |\n| `is_complex` | Returns whether this is a complex floating point type. |\n| `is_floating` | Returns whether this is a (non-quantized, real) floating point type. |\n| `is_integer` | Returns whether this is a (non-quantized) integer type. |\n| `is_numpy_compatible` | \u003cbr /\u003e \u003cbr /\u003e |\n| `is_quantized` | Returns whether this is a quantized data type. |\n| `is_unsigned` | Returns whether this type is unsigned. \u003cbr /\u003e Non-numeric, unordered, and quantized types are not considered unsigned, and this function returns `False`. |\n| `limits` | Return intensity limits, i.e. \u003cbr /\u003e (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. |\n| `max` | Returns the maximum representable value in this data type. |\n| `min` | Returns the minimum representable value in this data type. |\n| `name` | Returns the string name for this `DType`. |\n| `real_dtype` | Returns the dtype correspond to this dtype's real part. |\n| `size` | \u003cbr /\u003e \u003cbr /\u003e |\n\n\u003cbr /\u003e\n\nMethods\n-------\n\n### `is_compatible_with`\n\n[View source](https://github.com/tensorflow/tensorflow/blob/v2.0.0/tensorflow/python/framework/dtypes.py#L240-L258) \n\n is_compatible_with(\n other\n )\n\nReturns True if the `other` DType will be converted to this DType.\n\nThe conversion rules are as follows: \n\n DType(T) .is_compatible_with(DType(T)) == True\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ||\n|---------|-----------------------------------------------------------|\n| `other` | A `DType` (or object that may be converted to a `DType`). |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ||\n|---|---|\n| True if a Tensor of the `other` `DType` will be implicitly converted to this `DType`. ||\n\n\u003cbr /\u003e\n\n### `__eq__`\n\n[View source](https://github.com/tensorflow/tensorflow/blob/v2.0.0/tensorflow/python/framework/dtypes.py#L260-L268) \n\n __eq__(\n other\n )\n\nReturns True iff this DType refers to the same type as `other`.\n\n### `__ne__`\n\n[View source](https://github.com/tensorflow/tensorflow/blob/v2.0.0/tensorflow/python/framework/dtypes.py#L270-L272) \n\n __ne__(\n other\n )\n\nReturns True iff self != other."]]