Skip to content
Snippets Groups Projects
Commit 3e7d9497 authored by Falguni Ghosh's avatar Falguni Ghosh
Browse files

Upload New File

parent 4c2b4a1a
No related branches found
No related tags found
No related merge requests found
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)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment