Let's say I have a native pytorch model like this
class NormalAutoEncoder(nn.Module)):
def __init__(self):
super().__init__()
self.encoder = nn.Sequential(nn.Linear(28 * 28, 64), nn.ReLU(), nn.Linear(64, 3))
self.decoder = nn.Sequential(nn.Linear(3, 64), nn.ReLU(), nn.Linear(64, 28 * 28))
def forward(self, x):
# in lightning, forward defines the prediction/inference actions
embedding = self.encoder(x)
return embedding
How can I have the __init__ and forward functions (basically, the whole network) into a pytorch lighting module without copying and pasting?