TensorSpec

class dragon.TensorSpec(
  shape,
  dtype='float32',
  name=None
)[source]

Spec to describe properties of a tensor.

__init__

TensorSpec.__init__(
  shape,
  dtype='float32',
  name=None
)[source]

Create a TensorSpec.

Parameters:
  • shape (Sequence[int], required) – The dimensions.
  • dtype (str, optional, default='float32') – The optional data type.
  • name (str, optional) – The optional name.

Properties

dtype

TensorSpec.dtype

Return the data type.

Returns:
str – The data type.

name

TensorSpec.name

Return the spec name.

Returns:
str – The spec name.

shape

TensorSpec.shape

Return the dimensions.

Returns:
Sequence[int] – The dimensions.

Methods

is_compatible_with

TensorSpec.is_compatible_with(spec_or_tensor)[source]

Return a bool indicating whether given the spec is compatible.

Returns:
boolTrue if shape and dtype are both compatible otherwise False.