Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IndexError when trying to train a network with N = 2 #2

Open
ianwilliamson opened this issue Dec 6, 2018 · 1 comment
Open

IndexError when trying to train a network with N = 2 #2

ianwilliamson opened this issue Dec 6, 2018 · 1 comment

Comments

@ianwilliamson
Copy link
Contributor

Not sure if I am doing something stupid, but I get the following error when trying to train a mesh of dimension N = 2.

---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
<ipython-input-64-b9c14e8893da> in <module>
     23 Y_formatted = Y.T
     24 
---> 25 losses = neu.InSituAdam(model, neu.CategoricalCrossEntropy, step_size=0.005).fit(X_formatted, Y_formatted, epochs=1000, batch_size=32)
     26 
     27 plt.plot(losses)

~/drive/Research/Projects/ONN/neuroptica/neuroptica/optimizers.py in fit(self, data, labels, epochs, batch_size, show_progress)
    169 
    170                 # Compute the backpropagated signals for the model
--> 171                 deltas = self.model.backward_pass(d_loss)
    172                 delta_prev = d_loss  # backprop signal to send in the final layer
    173 

~/drive/Research/Projects/ONN/neuroptica/neuroptica/models.py in backward_pass(self, d_loss)
     59         gradients = {"output": d_loss}
     60         for layer in reversed(self.layers):
---> 61             backprop_signal = layer.backward_pass(backprop_signal)
     62             gradients[layer.__name__] = backprop_signal
     63         return gradients

~/drive/Research/Projects/ONN/neuroptica/neuroptica/layers.py in backward_pass(self, delta)
     50         delta_back = np.zeros((self.input_size, n_samples), dtype=NP_COMPLEX)
     51         for i in range(n_features):
---> 52             delta_back[self.ports[i]] = delta[i]
     53         return delta_back
     54 

IndexError: list index out of range
@ianwilliamson
Copy link
Contributor Author

Note that this is low priority to fix, just wanted to post it here to keep track of things.

@ianwilliamson ianwilliamson changed the title IndexError when N = 2 IndexError when trying to train a network with N = 2 Dec 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant