Package com.yahoo.tensor
Class MixedTensor
- java.lang.Object
-
- com.yahoo.tensor.MixedTensor
-
- All Implemented Interfaces:
Tensor
public class MixedTensor extends java.lang.Object implements Tensor
A mixed tensor type. This is class is currently suitable for serialization and deserialization, not yet for computation. A mixed tensor has a combination of mapped and indexed dimensions. By reordering the mapped dimensions before the indexed dimensions, one can think of mixed tensors as the mapped dimensions mapping to a dense tensor. This dense tensor is called a dense subspace.- Author:
- lesters
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
MixedTensor.BoundBuilder
Builder for mixed tensors with bound indexed dimensions.static class
MixedTensor.Builder
Base class for building mixed tensors.static class
MixedTensor.UnboundBuilder
Temporarily stores all cells to find bounds of indexed dimensions, then creates a tensor using BoundBuilder.-
Nested classes/interfaces inherited from interface com.yahoo.tensor.Tensor
Tensor.Cell
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.Iterator<Tensor.Cell>
cellIterator()
Returns an iterator over the cells of this tensor.java.util.Map<TensorAddress,java.lang.Double>
cells()
Returns an immutable map of the cells of this in no particular order.static TensorType
createPartialType(TensorType.Value valueType, java.util.List<TensorType.Dimension> dimensions)
long
denseSubspaceSize()
Returns the size of dense subspacesboolean
equals(java.lang.Object other)
Returns whether this tensor and the given tensor is mathematically equal: That they have the same dimension *names* and the same content.double
get(TensorAddress address)
Returns the value at the given addressint
hashCode()
Tensor
remove(java.util.Set<TensorAddress> addresses)
Returns a new tensor where existing cells in this tensor have been removed according to the given set of addresses.long
size()
Returns the size of the tensor measured in number of cellsjava.lang.String
toString()
Returns this tensor on the tensor literal form with type included.TensorType
type()
Returns the tensor typejava.util.Iterator<java.lang.Double>
valueIterator()
Returns an iterator over the values of this tensor.Tensor
withType(TensorType other)
Returns this tensor with the given type if types are compatible-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.yahoo.tensor.Tensor
add, approxEqual, argmax, argmin, asDouble, atan2, avg, avg, avg, concat, concat, count, count, count, divide, equal, fmod, isEmpty, join, l1Normalize, l2Normalize, larger, largerOrEqual, largest, ldexp, map, matmul, max, max, max, max, merge, min, min, min, min, modify, multiply, notEqual, pow, prod, prod, prod, reduce, reduce, rename, rename, smaller, smallerOrEqual, smallest, softmax, subtract, sum, sum, sum, xwPlusB
-
-
-
-
Method Detail
-
type
public TensorType type()
Returns the tensor type
-
size
public long size()
Returns the size of the tensor measured in number of cells
-
get
public double get(TensorAddress address)
Returns the value at the given address
-
cellIterator
public java.util.Iterator<Tensor.Cell> cellIterator()
Returns an iterator over the cells of this tensor. Cells are returned in order of increasing indexes in the indexed dimensions, increasing indexes of later dimensions in the dimension type before earlier. No guarantee is given for the order of sparse dimensions.- Specified by:
cellIterator
in interfaceTensor
-
valueIterator
public java.util.Iterator<java.lang.Double> valueIterator()
Returns an iterator over the values of this tensor. The iteration order is the same as for cellIterator.- Specified by:
valueIterator
in interfaceTensor
-
cells
public java.util.Map<TensorAddress,java.lang.Double> cells()
Description copied from interface:Tensor
Returns an immutable map of the cells of this in no particular order. This may be expensive for some implementations - avoid when possible
-
withType
public Tensor withType(TensorType other)
Description copied from interface:Tensor
Returns this tensor with the given type if types are compatible
-
remove
public Tensor remove(java.util.Set<TensorAddress> addresses)
Description copied from interface:Tensor
Returns a new tensor where existing cells in this tensor have been removed according to the given set of addresses. Only valid for sparse or mixed tensors. For mixed tensors, addresses are assumed to only contain the sparse dimensions, as the entire dense subspace is removed.
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
toString
public java.lang.String toString()
Description copied from interface:Tensor
Returns this tensor on the tensor literal form with type included.
-
equals
public boolean equals(java.lang.Object other)
Description copied from interface:Tensor
Returns whether this tensor and the given tensor is mathematically equal: That they have the same dimension *names* and the same content.
-
denseSubspaceSize
public long denseSubspaceSize()
Returns the size of dense subspaces
-
createPartialType
public static TensorType createPartialType(TensorType.Value valueType, java.util.List<TensorType.Dimension> dimensions)
-
-