From 120f9ff6b36ed8152a996c28a0e1007eca551d30 Mon Sep 17 00:00:00 2001
From: Falguni Ghosh <falguni.ghosh@fau.de>
Date: Sun, 15 Oct 2023 21:05:52 +0000
Subject: [PATCH] Upload New File

---
 2_CNN/Initializers.py | 49 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 49 insertions(+)
 create mode 100644 2_CNN/Initializers.py

diff --git a/2_CNN/Initializers.py b/2_CNN/Initializers.py
new file mode 100644
index 0000000..f046fe5
--- /dev/null
+++ b/2_CNN/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
-- 
GitLab