Part 2 lesson 11 wiki

Solution found here : https://github.com/facebookresearch/fastText/issues/411
for everyone having problems when compiling fasttext under Windows like @KarlH , @Chris_Palmer and me.

I can’t believe that it’s not already updated (since january) as it’s only a missing #include.
To summarize :

  • git clone https://github.com/facebookresearch/fastText.git
  • modify fasttext/src/productquantizer.cc and add : #include <string>
  • open an anaconda prompt, access the fastai env, then go to the fastText sources directory and run : pip install .

Are my two pickle.dump files useable?

Yes, it worked well ! Thanks again.
I’ve used them to continue with the notebook before I found a solution to compile fasttext. And anyway it’s a lot smaller than the fasttext files for wiki models in EN and FR (that I even not finished to download yet).

Thanks for this @pascal !

I noticed that the readme suggests that you use the latest stable release:

Did you just use the master branch with no issues?

Hi @Chris_Palmer. You can see in commits that there are only few commits, some fix and updates on docs so no new features. IMO you can definitely use the master branch. I do not get any issue with it for now.

Hi, I’m trying to increase the number of layers from 2 to 3 in the final model “Seq2SeqRNN_All” to make it more expressive. I removed the nl=2 hardcoding in init().

However, when I try and run .fit() I get the following error. Does anyone know where my dimension mismatch is coming from and what I should change? As a new user I can only attach 1 image, but I added as much of the error trace as possible. Thank you!

Hi, I am kind of late here but I wonder if anyone try download the full imagenet data to run devise section? The val folder seems different compared to the jupyter notebook, instead it now contains just the JPEG files with xml annotation in another folder. Just thought the codes below would be useful to someone for grabbing the fast text word vector using the synset to word vector ( syn2wv ).

import xml.etree.ElementTree as ET

images = []
img_vecs = []

n_trn = 0
for d in (PATH/'ILSVRC/Data/CLS-LOC/train').iterdir():
    if d.name not in syn2wv: continue
    vec = syn2wv[d.name]
    for f in d.iterdir():
        images.append(str(f.relative_to(PATH)))
        img_vecs.append(vec)
        n_trn +=1

n_val=0
for d in (PATH/'ILSVRC/Data/CLS-LOC/val/').iterdir():
    vname = d.name.split('.')[0]
    extract = ET.parse(os.path.join(PATH/'ILSVRC/Annotations/CLS-LOC/val/',vname +'.xml'))
    dname = extract.getroot()[-1][0].text   # object-name
    #print(vname, dname)
    if dname not in syn2wv: continue
    #print('OK', dname)
    vec = syn2wv[dname]
    images.append(str(d.relative_to(PATH)))
    img_vecs.append(vec)
    n_val += 1

n_trn, n_val
(739526, 28700)

1 Like

was the topic of stacked RNN covered before? Jermey mentioned that in this session but I relooked at lesson 6 and lesson 7 of part one and I cannot seem to find any difference about different structures RNN cells are put together. Am I missing something?

Regarding the devise notebook, can we use parallel GPUs?
I tried

models = ConvnetBuilder(arch, md.c, is_multi=False, is_reg=True, xtra_fc=[1024], ps=[0.2,0.2])
models = nn.DataParallel(models, device_ids=[0, 1, 2, 3])
learn = ConvLearner(md, models, precompute=True)
learn.opt_fn = partial(optim.Adam, betas=(0.9,0.99))

But i got an error

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-59-ee48c5dc5c68> in <module>()
----> 1 learn = ConvLearner(md, models, precompute=True)
      2 #learn = ConvLearner.from_model_data(md, models, precompute=True)
      3 learn.opt_fn = partial(optim.Adam, betas=(0.9,0.99))

/opt/conda/lib/python3.6/site-packages/fastai/conv_learner.py in __init__(self, data, models, precompute, **kwargs)
     98         if hasattr(data, 'is_multi') and not data.is_reg and self.metrics is None:
     99             self.metrics = [accuracy_thresh(0.5)] if self.data.is_multi else [accuracy]
--> 100         if precompute: self.save_fc1()
    101         self.freeze()
    102         self.precompute = precompute

/opt/conda/lib/python3.6/site-packages/fastai/conv_learner.py in save_fc1(self)
    162 
    163     def save_fc1(self):
--> 164         self.get_activations()
    165         act, val_act, test_act = self.activations
    166         m=self.models.top_model

/opt/conda/lib/python3.6/site-packages/fastai/conv_learner.py in get_activations(self, force)
    153 
    154     def get_activations(self, force=False):
--> 155         tmpl = f'_{self.models.name}_{self.data.sz}.bc'
    156         # TODO: Somehow check that directory names haven't changed (e.g. added test set)
    157         names = [os.path.join(self.tmp_path, p+tmpl) for p in ('x_act', 'x_act_val', 'x_act_test')]

/opt/conda/lib/python3.6/site-packages/torch/nn/modules/module.py in __getattr__(self, name)
    396                 return modules[name]
    397         raise AttributeError("'{}' object has no attribute '{}'".format(
--> 398             type(self).__name__, name))
    399 
    400     def __setattr__(self, name, value):

AttributeError: 'DataParallel' object has no attribute 'name'

Naive question : does it exist a smaller Imagenet Dataset compatible with devise notebook ?
Thanks

Sorry found this
https://tiny-imagenet.herokuapp.com/
in the previous post

Anyone tried to fit a LM for the seq2seq?
Seems a very interesting area and I wonder if there is any paper or anyone that tried it

Thank you for this amazing post, @phaniteja. Thank you too for the equally amazing reply, @stemill. I benefited a lot, but only after reading them several times :joy:

Would you be kind enough to make your notebook available? I’m would like to use it to troubleshoot my crappy translation

I happen to be scrutinizing that notebook . Seems like you are asking about the section on teacher-forcing, but I’m not sure what are you asking :thinking:?

Didn’t saw this part

if (y is not None) and (random.random()<self.pr_force):
    if i>=len(y): break
    dec_inp = y[i]

My bad, actually I was trying to create a similar network with keras using attention mechanism. Due to static graphs, I wasn’t able to create one with teacher-forcing method.

i believe jeremy said during the video lecture that he switched to pytorch precisely because it was difficult to implement teacher forcing on tensorflow, so perhaps don’t try too hard on this

https://github.com/facebookresearch/fastText/blob/master/pretrained-vectors.md

The link found in the translate notebook (shown above) to the fasttext word vectors has changed. Googling around and browsing the base url repo, I can’t find what would work as a replacement.

https://fasttext.cc/docs/en/english-vectors.html maybe will work. But it’s only English and definitely from a different corpus source, which I guess is fine, I just won’t reproduce the notebook.

Any tips?

EDIT:
Ah this seems to be what I want: https://fasttext.cc/docs/en/pretrained-vectors.html

Why is SortishSampler using the English (target) set for the sorting? Since it is translating French to English in this example, I would expected the fr_trn set to be used, in stead of the en_trn set to keep all the training data in relative same sizes…Or is it more important that the target, and therefore the output activations are of similar size?

Hi All,

I have been trying to follow along this lesson, however I am struggling to understand why my predictions end with several “eos eos eos”. Also, words are repeated several times no matter how much better the scores get. For example, predictions like, “you are very very very late late eos eos eos”. I don’t believe I have changed the code either. Any ideas?

Hi all,

I have problems with running the lesson material myself, on my computer (I have been able to run more other ones)
After the Word vectors title, fastText gets being used. I am able to import it, but then I come to this line:
To use the fastText library, you’ll need to download fasttext word vectors for your language (download the ‘bin plus text’ ones).
And the link is dead! So if I run the next block of code, it says: AttributeError: module ‘fastText’ has no attribute ‘load_model’

What should I do?

1 Like