Have a question? Connect with the community at the TensorFlow Forum Visit Forum

Glorot

public class Glorot

The Glorot initializer, also called Xavier initializer.

Draws samples from a random distribution.

If the distribution is TRUNCATED_NORMAL, then the distribution is centered on 0 with stddev = Math.sqrt(2. / (fanIn + fanOut)) where fanIn is the number of input units in the weight tensor and fanOut is the number of output units in the weight tensor.

If the distribution is UNIFORM, then samples are drawn from a uniform distribution within [-limit, limit] , where limit = sqrt(6 / (fanIn + fanOut)) ( fanIn is the number of input units in the weight tensor and fanOut is the number of output units).

Examples:

Glorot Normal:

     long seed = 1001l;
     Glorot<TFloat32, TFloat32> initializer =
             new org.tensorflow.framework.initializers.Glorot<>(tf,
             Distribution.TRUNCATED_NORMAL, seed);
     Operand<TFloat32> values =
             initializer.call(tf.constant(Shape.of(2,2)), TFloat32.class);
 

Glorot Uniform:

    long seed = 1001l;
    Glorot<TFloat32, TFloat32> initializer =
             new org.tensorflow.framework.initializers.Glorot<>(tf,
             Distribution.UNIFORM, seed);
     Operand<TFloat32> values =
             initializer.call(tf.constant(Shape.of(2,2)), TFloat32.class);
 

NOTE:

For a GlorotNormal equivalent initializer, use TRUNCATED_NORMAL for the distribution parameter.

For a GlorotUniform equivalent initializer, use UNIFORM for the distribution parameter.

Constants

double SCALE

Inherited Constants

Inherited Fields

Public Constructors

Glorot (Ops tf, VarianceScaling.Distribution distribution, long seed)
Creates a Glorot initializer

Inherited Methods

Constants

public static final double SCALE

Constant Value: 1.0

Public Constructors

public Glorot (Ops tf, VarianceScaling.Distribution distribution, long seed)

Creates a Glorot initializer

Parameters
tf the TensorFlow Ops
distribution The distribution type for the Glorot initializer.
seed the seed for random number generation. An initializer created with a given seed will always produce the same random tensor for a given shape and dtype.