Class RandomWeights


  • public class RandomWeights
    extends java.lang.Object
    This class provides various randomization methods.
    Author:
    Zoran Sevarac
    • Constructor Summary

      Constructors 
      Constructor Description
      RandomWeights()  
    • Method Summary

      Modifier and Type Method Description
      static void gaussian​(float[] weights, float mean, float std)  
      static void he​(float[] weights, int numInputs)  
      static void initSeed​(long seed)  
      static void normal​(float[] weights)  
      static void randomize​(float[] array)
      Fills the specified array with random numbers in range [-0.5, 0.5] from the current random seed
      static void uniform​(float[] weights, float min, float max)  
      static void uniform​(float[] weights, int numInputs)
      Uniform U[-a,a] where a=1/sqrt(in).
      static void widrowHoff​(float[] array, float input, float hidden)  
      static void xavier​(float[] weights, int numIn, int numOut)
      Normalized uniform initialization U[-a,a] with a = sqrt(6/(in + out)).
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • initSeed

        public static void initSeed​(long seed)
      • randomize

        public static void randomize​(float[] array)
        Fills the specified array with random numbers in range [-0.5, 0.5] from the current random seed
        Parameters:
        array -
      • widrowHoff

        public static void widrowHoff​(float[] array,
                                      float input,
                                      float hidden)
      • uniform

        public static void uniform​(float[] weights,
                                   int numInputs)
        Uniform U[-a,a] where a=1/sqrt(in).
        Parameters:
        weights - an array of weights
        numInputs - number of inputs, a size of the previous layer
      • uniform

        public static void uniform​(float[] weights,
                                   float min,
                                   float max)
      • he

        public static void he​(float[] weights,
                              int numInputs)
      • gaussian

        public static void gaussian​(float[] weights,
                                    float mean,
                                    float std)
      • normal

        public static void normal​(float[] weights)
      • xavier

        public static void xavier​(float[] weights,
                                  int numIn,
                                  int numOut)
        Normalized uniform initialization U[-a,a] with a = sqrt(6/(in + out)).
        Parameters:
        weights -
        numIn - size of the previous layer (number of inputs)
        numOut - size of initialized layer (number of outputs)