pythonpytorchtorchtext

Error in loading Glove vectors using TorchText on Kaggle Kernel


I am trying to load the Glove embedding vectors in kaggle kernel using TorchText lib.

from torchtext import vocab
vec = vocab.Vectors('glove.6B.100d.txt', '../input/glove6b100dtxt/')

I am getting the following error:

OSError: [Errno 30] Read-only file system: '../input/glove6b100dtxt/glove.6B.100d.txt.pt'

Adding screenshot for more clarification: enter image description here


Solution

  • This happens when you are using glove embeddings as part of the input from other datasets. You don't have the right access to the input folder so the workaround is as follows :

    Now we will load the Glove Embedding and move it out to the working directory

    !cp -r ../input/glove-embeddings/ ../kaggle/working/glove-embeddings
    

    Once moved, change the location of access

    vec = vocab.Vectors('glove.6B.100d.txt', '../kaggle/working/glove-embeddings')