Package com.yahoo.tensor
Class Tensors
java.lang.Object
com.yahoo.tensor.Tensors
Tensor convenience functions.
- Author:
- bratseth
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic TensorConverts any tensor into one where each consecutive 8 values in the dense dimension are packed into a single byte, by setting a bit to 1 when the tensor has a positive value and 0 otherwise.static TensorConverts the given dimensions from dense to sparse.
-
Constructor Details
-
Tensors
public Tensors()
-
-
Method Details
-
toSparse
Converts the given dimensions from dense to sparse. Any given dimension which is already dense is left as is.- Parameters:
tensor- the tensor to convertdimensions- the dimensions to convert from dense to sparse. If no dimensions are given, all dimensions are converted.- Returns:
- a tensor where the specified dimensions are converted from dense to sparse
- Throws:
IllegalArgumentException- if the given tensor does not have all the specified dimensions
-
packBits
Converts any tensor into one where each consecutive 8 values in the dense dimension are packed into a single byte, by setting a bit to 1 when the tensor has a positive value and 0 otherwise. As a consequence the output type of this is a tensor where the dense dimension is 1/8th as large.- Throws:
IllegalArgumentException- if the tensor has the wrong type or contains any other value than 0 or 1
-