lingvo.core.tshape module

Symbolic representation of tensor shapes.

class lingvo.core.tshape.Shape(dims)[source]

Bases: object

Shape represents a tensor’s symbolic shape.

property rank

Returns the rank of the tensor.

property size

Returns the size (num of elements) of the tensor.

num_elements()[source]

Returns the size (num of elements) of the tensor.

Subs(bindings)[source]

Substitute symbols with new values.

Parameters

bindings – key/value items correspond to old/new pairs for substitution.

Returns

The Shape with symbols substituted according to bindings.

ToTensorShape()[source]

Converts to a possibly partially specified tf.TensorShape.