diff --git a/3_RNN/Initializers.py b/3_RNN/Initializers.py new file mode 100644 index 0000000000000000000000000000000000000000..f046fe513a69404b1709cfbd9af4792c8cd2675e --- /dev/null +++ b/3_RNN/Initializers.py @@ -0,0 +1,49 @@ +import numpy as np + + +class Constant: + + def __init__(self, constant=0.1): + self.constant = constant + + def initialize(self, weights_shape, fan_in, fan_out): + output = (np.ones(weights_shape))*self.constant + + return output + + +class UniformRandom: + + def __init__(self): + self.low = None + self.high = None + + def initialize(self, weights_shape, fan_in, fan_out): + self.low = 0 + self.high = 1 + output = np.random.uniform(self.low, self.high, weights_shape) + return output + + +class Xavier: + + def __init__(self): + self.std = None + + def initialize(self, weights_shape, fan_in, fan_out): + self.std = np.sqrt(2 / (fan_in + fan_out)) + output = np.random.normal(0, self.std, weights_shape) + + return output + + +class He: + + def __init__(self): + self.std = None + + def initialize(self, weights_shape, fan_in, fan_out): + self.std = np.sqrt(2 / fan_in) + output = np.random.normal(0, self.std, weights_shape) + + return output