If you don’t specify any activation functions on torch.nn.Linear, is the default the identity activation?
If so, in a network where you have only have fully connected layers (torch.nn.Linear) with identity activation, you can just replace all fully connected layers with a single fully connected layer?
I.e., the following 2 are equivalent:
class LinearRegressionModel(nn.Module):
def init(self):
super().init()# self.fc1 = nn.Linear(num_TCs * num_time_steps, 500) self.fc1 = nn.Linear(100, 1) self.fc2 = nn.Linear(100, 500) self.fc3 = nn.Linear(500, 250) self.fc4 = nn.Linear(250, 1)
def forward(self, x):
out = self.fc1(out) return out
class LinearRegressionModel(nn.Module):
def init(self):
super().init()self.fc1 = nn.Linear(100, 100) self.fc2 = nn.Linear(100, 500) self.fc3 = nn.Linear(500, 250) self.fc4 = nn.Linear(250, 1)
def forward(self, x):
out = self.fc1(out)
out = self.fc2(out)
out = self.fc3(out)
out = self.fc4(out)return out