Package com.yahoo.tensor
Class MixedTensor
java.lang.Object
com.yahoo.tensor.MixedTensor
- All Implemented Interfaces:
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 ClassesModifier and TypeClassDescriptionstatic classBuilder for mixed tensors with bound indexed dimensions.static classBase class for building mixed tensors.static final classonly exposed for internal use; subject to change without noticeNested classes/interfaces inherited from interface com.yahoo.tensor.Tensor
Tensor.Cell -
Field Summary
Fields inherited from interface com.yahoo.tensor.Tensor
invalidIndex -
Method Summary
Modifier and TypeMethodDescriptionReturns an iterator over the cells of this tensor.cells()Returns an immutable map of the cells of this in no particular order.static TensorTypecreatePartialType(TensorType.Value valueType, List<TensorType.Dimension> dimensions) longReturns the size of dense subspacesbooleanReturns whether this tensor and the given tensor is mathematically equal: That they have the same dimension *names* and the same content.doubleget(TensorAddress address) Returns the value at the given addressgetAsDouble(TensorAddress address) Returns the value at this address, or null of it does not exist.only exposed for internal use; subject to change without noticebooleanhas(TensorAddress address) Returns true if this cell existsinthashCode()Returns a hash computed deterministically from the content of this tensorremove(Set<TensorAddress> addresses) Returns a new tensor where existing cells in this tensor have been removed according to the given set of addresses.longsize()Returns the size of the tensor measured in number of cellstoAbbreviatedString(boolean withType, boolean shortForms) Returns an abbreviated string representation of this tensor suitable for human-readable messagestoString()Returns this tensor on the tensor literal form with type included.toString(boolean withType, boolean shortForms) Returns this tensor on the tensor literal form.type()Returns the tensor typeReturns an iterator over the values of this tensor.withType(TensorType other) Returns this tensor with the given type if types are compatibleMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods 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, sizeAsInt, smaller, smallerOrEqual, smallest, softmax, subtract, sum, sum, sum, toAbbreviatedString, xwPlusB
-
Method Details
-
getInternalDenseSubspaces
only exposed for internal use; subject to change without notice -
type
Returns the tensor type -
size
public long size()Returns the size of the tensor measured in number of cells -
get
Returns the value at the given address -
getAsDouble
Description copied from interface:TensorReturns the value at this address, or null of it does not exist.- Specified by:
getAsDoublein interfaceTensor
-
has
Description copied from interface:TensorReturns true if this cell exists -
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:
cellIteratorin interfaceTensor
-
valueIterator
Returns an iterator over the values of this tensor. The iteration order is the same as for cellIterator.- Specified by:
valueIteratorin interfaceTensor
-
cells
Description copied from interface:TensorReturns an immutable map of the cells of this in no particular order. This may be expensive for some implementations - avoid when possible -
withType
Description copied from interface:TensorReturns this tensor with the given type if types are compatible -
remove
Description copied from interface:TensorReturns a new tensor where existing cells in this tensor have been removed according to the given set of addresses. Only valid for mapped or mixed tensors. For mixed tensors, addresses are assumed to only contain the mapped dimensions, as the entire indexed subspace is removed. -
hashCode
public int hashCode()Description copied from interface:TensorReturns a hash computed deterministically from the content of this tensor -
toString
Description copied from interface:TensorReturns this tensor on the tensor literal form with type included. -
toString
Description copied from interface:TensorReturns this tensor on the tensor literal form. -
toAbbreviatedString
Description copied from interface:TensorReturns an abbreviated string representation of this tensor suitable for human-readable messages- Specified by:
toAbbreviatedStringin interfaceTensor- Parameters:
withType- whether to prefix the value by the type of thisshortForms- whether to use short forms where applicable, or always using the verbose form
-
equals
Description copied from interface:TensorReturns 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)
-