I’m not sure I understand your code correctly, but there might be some parts missing.
E.g. your model is currently a single linear layer with two ReLUs afterwards.
It seems the output layer is missing.
Also, in your my_loss method you are calculating torch.mean((output-output)+ftn), so basically just torch.mean(ftn). Since testnetwork is missing, I’m not sure what fitness does and how your loss is supposed to work.
Could you check these issues or explain them a bit if I’m missing something?