Package com.yahoo.tensor
Class MappedTensor
- java.lang.Object
-
- com.yahoo.tensor.MappedTensor
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
MappedTensor.Builder
-
Nested classes/interfaces inherited from interface com.yahoo.tensor.Tensor
Tensor.Cell
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Iterator<Tensor.Cell>
cellIterator()
Returns the cell of this in some undefined order.Map<TensorAddress,Double>
cells()
Returns an immutable map of the cells of this in no particular order.boolean
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 of a cell, or 0.0 if this cell does not existboolean
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 number of cells in thisString
toString()
Returns this tensor on the tensor literal form with type included.TensorType
type()
Iterator<Double>
valueIterator()
Returns the values of this in some undefined orderTensor
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()
-
size
public long size()
Description copied from interface:Tensor
Returns the number of cells in this
-
get
public double get(TensorAddress address)
Description copied from interface:Tensor
Returns the value of a cell, or 0.0 if this cell does not exist
-
has
public boolean has(TensorAddress address)
Description copied from interface:Tensor
Returns true if this cell exists
-
cellIterator
public Iterator<Tensor.Cell> cellIterator()
Description copied from interface:Tensor
Returns the cell of this in some undefined order. A cell instances is only valid until next() is called. Call detach() on the cell to obtain a long-lived instance.- Specified by:
cellIterator
in interfaceTensor
-
valueIterator
public Iterator<Double> valueIterator()
Description copied from interface:Tensor
Returns the values of this in some undefined order- 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.
-
-