Class Tensors

java.lang.Object
com.yahoo.tensor.Tensors

public class Tensors extends Object
Tensor convenience functions.
Author:
bratseth
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static Tensor
    packBits(Tensor tensor)
    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.
    static Tensor
    toSparse(Tensor tensor, String... dimensions)
    Converts the given dimensions from dense to sparse.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Tensors

      public Tensors()
  • Method Details

    • toSparse

      public static Tensor toSparse(Tensor tensor, String... dimensions)
      Converts the given dimensions from dense to sparse. Any given dimension which is already dense is left as is.
      Parameters:
      tensor - the tensor to convert
      dimensions - 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

      public static Tensor packBits(Tensor tensor)
      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