Skip to content

Instantly share code, notes, and snippets.

Created March 6, 2018 23:34
What would you like to do?
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Copy link

Thank you for sharing. It helped me to understand word2vec

Copy link

Code4luv commented Jan 5, 2022

Thank you for sharing the code.

Please mention how to save the model for future use or analysis? I have already started training on very large data using Pycharm. Please let me know the solution how can I use it the same in the future without stopping the current training.

Copy link

theBull commented Feb 9, 2022

I'm getting the following exception in the final cell when attempting to run this in a fresh Google Colab notebook:

IndexError                                Traceback (most recent call last)
[<ipython-input-10-400456173921>](https://localhost:8080/#) in <module>()
     18         loss = F.nll_loss(log_softmax.view(1,-1), y_true)
---> 19         loss_val +=[0]
     20         loss.backward()
     21 -= learning_rate *

IndexError: invalid index of a 0-dim tensor. Use `tensor.item()` in Python or `tensor.item<T>()` in C++ to convert a 0-dim tensor to a number

To fix this, I Googled the above error and followed the workaround described in this GitHub issue:

The fix is to change line 19 from:
loss_val +=[0]
loss_val +=

I believe this is an issue with the version of one of the libraries (PyTorch?) that was used the code above versus the version I am using now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment