Package deepboof.misc

Class TensorFactory_F32

java.lang.Object
deepboof.misc.TensorFactory_F32

public class TensorFactory_F32
extends java.lang.Object
Various functions for unit tests
  • Constructor Summary

    Constructors 
    Constructor Description
    TensorFactory_F32()  
  • Method Summary

    Modifier and Type Method Description
    static Tensor_F32 random​(java.util.Random rand, boolean subTensor, int... shape)
    Creates a random tensor with the specified shape and values from -1 to 1
    static Tensor_F32 randomMM​(java.util.Random rand, boolean subTensor, float min, float max, int... shape)
    Creates a random tensor with the specified shape and value range
    static java.util.List<Tensor_F32> randomMM​(java.util.Random rand, boolean subTensor, float min, float max, java.util.List<int[]> shapes)
    Creates a random tensor with the specified shape and value range
    static void randomMM​(java.util.Random rand, float min, float max, Tensor_F32 tensor)
    Fills the tensor with random numbers selected from a uniform distribution.
    static Tensor_F32 zeros​(java.util.Random rand, int... shape)
    Generate a zeros tensor with the option for a sub-tensor

    Methods inherited from class java.lang.Object

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

  • Method Details

    • zeros

      public static Tensor_F32 zeros​(java.util.Random rand, int... shape)
      Generate a zeros tensor with the option for a sub-tensor
      Parameters:
      rand - If you wish to generate a sub-matrix pass in this RNG and it will randomly offset the data. null for regular tensor
      shape - Shape of the tensor
      Returns:
      tensor
    • random

      public static Tensor_F32 random​(java.util.Random rand, boolean subTensor, int... shape)
      Creates a random tensor with the specified shape and values from -1 to 1
      Parameters:
      rand - Random number generator
      subTensor - Should it be a sub-tensor or not?
      shape - Shape of the tensor
      Returns:
      The random tensor
    • randomMM

      public static Tensor_F32 randomMM​(java.util.Random rand, boolean subTensor, float min, float max, int... shape)
      Creates a random tensor with the specified shape and value range
      Parameters:
      rand - Random number generator
      subTensor - Should it be a sub-tensor or not?
      min - Minimum value of each element
      max - Maximum value of each element
      shape - Shape of the tensor
      Returns:
      The random tensor
    • randomMM

      public static java.util.List<Tensor_F32> randomMM​(java.util.Random rand, boolean subTensor, float min, float max, java.util.List<int[]> shapes)
      Creates a random tensor with the specified shape and value range
      Parameters:
      rand - Random number generator
      subTensor - Should it be a sub-tensor or not?
      min - Minimum value of each element
      max - Maximum value of each element
      shapes - Shapes of the tensors
      Returns:
      The random tensor
    • randomMM

      public static void randomMM​(java.util.Random rand, float min, float max, Tensor_F32 tensor)
      Fills the tensor with random numbers selected from a uniform distribution.
      Parameters:
      rand - Random number generator
      min - min value, inclusive
      max - max value, inclusive
      tensor - Tensor that is to be filled.