Given a tensor shape (3, 256, 256). I would like to convolute or loop through it pixel by pixel to return me a tensor shape (1, 256, 256).
This may sound a bit confusing so here is my code till now so you know I mean.
class MorphNetwork(nn.Module):
def __init__(self):
super().__init__()
self.fc1 = nn.Linear(3, 8)
self.fc2 = nn.Linear(8, 1)
def forward(self, x):
# The input here is shape (3, 256, 256)
x = F.relu(self.fc1(x))
x = self.fc2(x)
# Returned shape should be (1, 256, 256)
return x
As you can see my Linear layer accept's shape 3 which matches the depth of my original tensor. What is the best way of looping through all 256x256 to return me tensor shape (1, 256, 256)