DiffEqML / torchdyn

A PyTorch library entirely dedicated to neural differential equations, implicit models and related numerical methods
https://torchdyn.org
Apache License 2.0
1.4k stars 130 forks source link

Changing number of Gaussians #75

Closed nstlz closed 3 years ago

nstlz commented 3 years ago

I'm having trouble changing the number of Gaussians above 2 in code I'm slightly modifying from the tutorials.

d = ToyDataset()
n_samples = 1 << 14
n_gaussians = 4
X, yn = d.generate(n_samples // n_gaussians, 'gaussians', n_gaussians=n_gaussians, std_gaussians=0.5, radius=4, dim=2)
X = (X - X.mean())/X.std()

When I try to compute loss loss = nn.CrossEntropyLoss()(y_hat, y), for any value of n_samples larger than 2, I get a error saying IndexError: Target 3 is out of bounds.

Any suggestions as to what I am missing?

Thank you so much!

Zymrael commented 3 years ago

In this case y will be the labels and if you add a new Gaussians the labels for it will be of a new class, in which case you need to add an additional output to your classifier.