Added vocab
and vocab_size
to CBOW exercise
#80
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I just went through the NLP tutorial - which is awesome btw - and got stuck with the CBOW exercise. I'm fairly new to the topic so excuse me if I am missing out a crucial point here.
Right now,
word_to_ix
is derived fromraw_text
, which causes e.g. the word 'computer' to be indexed with 58.If understand correctly, the goal is to predict the word which is in the center of 2 context words on each side respectively, causing the probability distribution to contain
len(set(raw_text))
values.Someone like me who is new to this topic will go ahead and follow the same approach as previously shown in the NGram example:
This will cause the code to break as soon as you hit a
context_vector
containing a word (such as 'computer') which is indexed higher thanword_to_ix
's length (in this case 49).Hence, I propose following boilerplate: