ParamSpec

class tfsnippet.utils.ParamSpec(*args, **kwargs)

Bases: tfsnippet.utils.tensor_spec.TensorSpec

Class to describe the specification for a parameter.

Unlike TensorSpec, the shape of the parameter must be fully determined, i.e., without any unknown dimension, and the ndims must be identical to the specification.

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.