Package ai.djl.training.initializer
Class TruncatedNormalInitializer
- java.lang.Object
-
- ai.djl.training.initializer.TruncatedNormalInitializer
-
- All Implemented Interfaces:
Initializer
public class TruncatedNormalInitializer extends java.lang.Object implements Initializer
Naive implementation of a truncated normal initializer. Simply samples from a normal distribution and throws away anything outside two standard deviations.
-
-
Field Summary
-
Fields inherited from interface ai.djl.training.initializer.Initializer
ONES, ZEROS
-
-
Constructor Summary
Constructors Constructor Description TruncatedNormalInitializer()
Creates an instance ofTruncatedNormalInitializer
with a default sigma of 0.01.TruncatedNormalInitializer(float sigma)
Creates a TruncatedNormalInitializer initializer.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description NDArray
initialize(NDManager baseManager, Shape shape, DataType dataType)
Initializes a singleNDArray
.
-
-
-
Constructor Detail
-
TruncatedNormalInitializer
public TruncatedNormalInitializer()
Creates an instance ofTruncatedNormalInitializer
with a default sigma of 0.01.
-
TruncatedNormalInitializer
public TruncatedNormalInitializer(float sigma)
Creates a TruncatedNormalInitializer initializer.- Parameters:
sigma
- the standard deviation of the truncated normal distribution. Values outside (-2σ, 2σ) will be rejected.
-
-
Method Detail
-
initialize
public NDArray initialize(NDManager baseManager, Shape shape, DataType dataType)
Initializes a singleNDArray
.- Specified by:
initialize
in interfaceInitializer
- Parameters:
baseManager
- theNDManager
to create the newNDArray
inshape
- theShape
for the new NDArraydataType
- theDataType
for the new NDArray- Returns:
- the
NDArray
initialized with the manager and shape
-
-