DType

class dragon.vm.tensorflow.dtypes.DType(value)[source]

The basic data type.

Following data types are defined:

  • tf.float16: 16-bit half-precision floating-point.
  • tf.float32: 32-bit single-precision floating-point.
  • tf.float64: 64-bit double-precision floating-point.
  • tf.bfloat16: 16-bit truncated floating-point.
  • tf.complex64: 64-bit single-precision complex.
  • tf.complex128: 128-bit double-precision complex.
  • tf.int8: 8-bit signed integer.
  • tf.uint8: 8-bit unsigned integer.
  • tf.uint16: 16-bit unsigned integer.
  • tf.uint32: 32-bit unsigned integer.
  • tf.uint64: 64-bit unsigned integer.
  • tf.int16: 16-bit signed integer.
  • tf.int32: 32-bit signed integer.
  • tf.int64: 64-bit signed integer.
  • tf.bool: Boolean.
  • tf.string: String.
  • tf.qint8: Quantized 8-bit signed integer.
  • tf.quint8: Quantized 8-bit unsigned integer.
  • tf.qint16: Quantized 16-bit signed integer.
  • tf.quint16: Quantized 16-bit unsigned integer.
  • tf.qint32: Quantized 32-bit signed integer.
  • tf.variant: Values of arbitrary types.

__init__

DType.__init__(value)[source]

Create a DType.

Parameters:
  • value (str) – The string name.

Properties

as_numpy_dtype

DType.as_numpy_dtype

Return as the number of numpy data type.

Returns:
type – The data type number.

as_datatype_enum

DType.as_datatype_enum

Return as the enum value of data type.

Returns:
int – The enum value.

base_dtype

DType.base_dtype

Return the non-referenced data type.

Returns:
dragon.vm.tensorflow.dtypes.DType – The data type.

is_numpy_compatible

DType.is_numpy_compatible

Return whether this data type is compatible with numpy.

Returns:
boolTrue if compatible otherwise False.

is_bool

DType.is_bool

Return whether this is a boolean type.

Returns:
boolTrue if this is a boolean type otherwise False.

is_complex

DType.is_complex

Return whether this is a complex type.

Returns:
boolTrue if this is a complex type otherwise False.

is_floating

DType.is_floating

Return whether this is a floating type.

Returns:
boolTrue if this is a floating type otherwise False.

is_integer

DType.is_integer

Return whether this is a integer type.

Returns:
boolTrue if this is a integer type otherwise False.

is_quantized

DType.is_quantized

Return whether this is a quantized type.

Returns:
boolTrue if this is a quantized type otherwise False.

is_unsigned

DType.is_unsigned

Return whether this is an unsigned type.

Returns:
boolTrue if this is an unsigned type otherwise False.

limits

DType.limits

Return the numerical limits.

Parameters:
  • clip_negative (bool, optional, default=True) – True to return positive limits only.
Returns:

Tuple[number, number] – The limits.

max

DType.max

Return the max representable value.

Returns:
number – The max representable value.

min

DType.min

Return the min representable value.

Returns:
number – The min representable value

name

DType.name

Return the type name.

Returns:
str – The type name.

real_dtype

DType.real_dtype

Return the data type of real part.

Returns:
dragon.vm.tensorflow.dtypes.DType – The data type of real part.

Methods

is_compatible_with

DType.is_compatible_with(other)[source]

Return whether this data type can be converted as the other.

Parameters:
Returns:

boolTrue if compatible otherwise False.