|
@@ -5,12 +5,25 @@ import numpy as np
|
|
|
|
|
|
# Random generators
|
|
|
def uniform(layer):
|
|
|
+ """
|
|
|
+ To generate network weights
|
|
|
+ with a uniform distribution between -1.0 and 1.0
|
|
|
+ """
|
|
|
return np.random.uniform(low = -1.0, high = 1.0, size = layer.shape)
|
|
|
|
|
|
def gaussUnitDev(layer):
|
|
|
+ """
|
|
|
+ To generate network weights
|
|
|
+ with a gaussian distribution.
|
|
|
+ """
|
|
|
return np.random.normal(size = layer.shape)
|
|
|
|
|
|
def gaussAdaptedDev(layer):
|
|
|
+ """
|
|
|
+ To generate network weights
|
|
|
+ with a gaussian distribution
|
|
|
+ where standard deviation is adpted 1 / sqrt(nl - 1)
|
|
|
+ """
|
|
|
nl, _ = layer.shape
|
|
|
stdDev = 1 / np.sqrt(nl - 1)
|
|
|
return np.random.normal(scale = stdDev, size = layer.shape)
|
|
@@ -18,7 +31,9 @@ def gaussAdaptedDev(layer):
|
|
|
# Network weight initialization
|
|
|
def generate(activation, derivative, weightGenerator = None):
|
|
|
"""
|
|
|
- Weight generator can be
|
|
|
+ activation : function used on network outputs
|
|
|
+ derivative : the derivative of the activation function
|
|
|
+ weightGenerator : is one of
|
|
|
None
|
|
|
generator.uniform
|
|
|
generator.gaussUnitDev
|