Package com.yahoo.tensor
Class MixedTensor
- java.lang.Object
-
- com.yahoo.tensor.MixedTensor
-
- All Implemented Interfaces:
Tensor
public class MixedTensor extends 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 Iterator<Tensor.Cell>
cellIterator()
Returns an iterator over the cells of this tensor.Map<TensorAddress,Double>
cells()
Returns an immutable map of the cells of this in no particular order.static TensorType
createPartialType(TensorType.Value valueType, List<TensorType.Dimension> dimensions)
long
denseSubspaceSize()
Returns the size of dense subspacesboolean
equals(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 addressboolean
has(TensorAddress address)
Returns true if this cell existsint
hashCode()
Tensor
remove(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 cellsString
toString()
Returns this tensor on the tensor literal form with type included.TensorType
type()
Returns the tensor typeIterator<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, bit, cellCast, concat, concat, count, count, count, divide, equal, expand, fmod, hamming, isEmpty, join, l1Normalize, l2Normalize, larger, largerOrEqual, largest, ldexp, map, matmul, max, max, max, max, median, median, median, 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
-
has
public boolean has(TensorAddress address)
Description copied from interface:Tensor
Returns true if this cell exists
-
cellIterator
public 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 Iterator<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 Map<TensorAddress,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(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.
-
toString
public String toString()
Description copied from interface:Tensor
Returns this tensor on the tensor literal form with type included.
-
equals
public boolean equals(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, List<TensorType.Dimension> dimensions)
-
-