InputSpec

class tfsnippet.utils.InputSpec(shape=None, dtype=None)

Bases: tfsnippet.utils.tensor_spec.TensorSpec

Class to describe the specification for an input tensor.

Mostly identical with TensorSpec.

Attributes Summary

dtype Get the data type of the tensor.
shape Get the shape specification.
value_ndims Get the value shape ndims.
value_shape Get the value shape (the shape excluding leading “…”).

Methods Summary

validate(name, x) Validate the input tensor x.

Attributes Documentation

dtype

Get the data type of the tensor.

Returns:The data type, or None.
Return type:tf.DType or None
shape

Get the shape specification.

Returns:The value shape, or None.
Return type:tuple[int or str or None] or None
value_ndims

Get the value shape ndims.

Returns:The value shape ndims, or None.
Return type:int or None
value_shape

Get the value shape (the shape excluding leading “…”).

Returns:The value shape, or None.
Return type:tuple[int or str or None] or None

Methods Documentation

validate(name, x)

Validate the input tensor x.

Parameters:
  • name (str) – The name of the tensor, used in error messages.
  • x – The input tensor.
Returns:

The validated tensor.

Raises:

ValueError, TypeError – If x cannot pass validation.