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

---
 3_RNN/Flatten.py | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)
 create mode 100644 3_RNN/Flatten.py

diff --git a/3_RNN/Flatten.py b/3_RNN/Flatten.py
new file mode 100644
index 0000000..3beb7e6
--- /dev/null
+++ b/3_RNN/Flatten.py
@@ -0,0 +1,26 @@
+from .Base import BaseLayer
+import numpy as np
+
+
+class Flatten(BaseLayer):
+
+    def __init__(self):
+        super().__init__()
+        self.input_size = None
+
+    def forward(self, input_tensor):
+
+        self.input_size = np.asarray(input_tensor.shape)
+
+        output_shape = (self.input_size[0],np.prod(self.input_size[1::]))
+        output = np.empty(output_shape)
+
+        for i in range(self.input_size[0]):
+            curr_img = input_tensor[i]
+            output[i] = curr_img.reshape(1, -1).squeeze()
+
+        return output
+
+
+    def backward(self, error_tensor):
+        return error_tensor.reshape(self.input_size)
-- 
GitLab