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

Upload New File

parent 56b8aa72
Branches
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