You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Expected behavior
I expect there are no trainable parameters at the output layer, which was showing as 850. If I comment out self.fc3 (which was never used), this fixed the issue.
class VanillaLeNet5(nn.Module):
"""
Original implementation of LeNet5 paper
Args:
nn (_type_): _description_
"""
def __init__(self, in_channels=1, number_classes=10):
super(VanillaLeNet5, self).__init__()
# Convolutional layers
self.conv1 = nn.Conv2d(in_channels=in_channels, out_channels=6, kernel_size=5, stride=1)
# Conv2 layers
self.conv2 = Conv2Layer()
# Pooling layer weights and biases
self.pool = PoolingLayer(in_channels=6)
self.pool2 = PoolingLayer(in_channels=16)
# Fully connected layers
self.fc1 = nn.Linear(in_features=16*5*5, out_features=120)
self.fc2 = nn.Linear(in_features=120, out_features=84)
#self.fc3 = nn.Linear(in_features=84, out_features=number_classes)
# RBF layer
self.rbf = RBFLayer(in_features=84, out_features=10)
# Define image transformation
self.transform = transforms.Compose(
[transforms.ToTensor(), transforms.Resize(size=[32, 32])]
)
def tanh(self, x):
A = 1.7159
S = 2/3
return A * torch.tanh(S*x)
def forward(self, x):
# Convolutional layers
x = self.conv1(x)
x = self.tanh(x)
x = self.pool(x)
x = self.conv2(x)
x = self.tanh(x)
x = self.pool2(x)
# Flatten the output from the previous layer
x = torch.flatten(x, 1) # Keep batch dimension
# Fully connected layers
x = self.fc1(x)
x = self.tanh(x)
x = self.fc2(x)
x = self.tanh(x)
x = self.rbf(x)
return x
Describe the bug
Model takes into account unused layers when counting number of parameters
To Reproduce
Steps to reproduce the behavior:
Expected behavior
I expect there are no trainable parameters at the output layer, which was showing as 850. If I comment out self.fc3 (which was never used), this fixed the issue.
Screenshots
The text was updated successfully, but these errors were encountered: