I’ve been having some trouble with my neural net, as it’s outputting all negatives for all 200k test set data points. I know that this isn’t possible with ReLU activation, which is why I’m so concerned.
Here’s my neural net class:
class Net(nn.Module):
def __init__(self, *, dims:dict):
super(Net, self).__init__()
# Layer 1
self.fc_1 = nn.Linear(in_features = dims['input_dim'], out_features=dims['layer_1'])
self.actv_1 = nn.ReLU()
# Layer 2
self.fc_2 = nn.Linear(in_features = dims['layer_1'], out_features = dims['layer_2'])
self.actv_2 = nn.ReLU()
self.bn_2 = nn.BatchNorm1d(num_features = dims['layer_2'])
# Layer 3
self.fc_3 = nn.Linear(in_features = dims['layer_2'], out_features = dims['layer_3'])
self.actv_3 = nn.ReLU()
self.bn_3 = nn.BatchNorm1d(num_features=dims['layer_3'])
# initialize
xavier_normal_(self.fc_1.weight)
xavier_normal_(self.fc_2.weight)
xavier_normal_(self.fc_3.weight)
self.fc_output = nn.Linear(in_features = dims['layer_3'], out_features = dims['output_dim'])
def forward(self, x):
x = self.actv_1(self.fc_1(x))
x = self.actv_2(self.bn_2(self.fc_2(x)))
x = self.actv_3(self.bn_3(self.fc_3(x)))
return self.fc_output(x)
Is this something wrong with my weight initialization? If so, what other options should I use?
Thanks in advance!