dllacer:

How should I use the nn.CrossEntropyLoss for a regression problem?


That won’t be possible, since you would need to provide class indices to calculate the cross entropy.
Based on “the goal is to make the network output look as much as the target as possible”, it seems indeed that you might be working on a regression problem, so you could use e.g. nn.MSELoss instead.