nfmcclure / tensorflow_cookbook

Code for Tensorflow Machine Learning Cookbook
https://www.packtpub.com/big-data-and-business-intelligence/tensorflow-machine-learning-cookbook-second-edition
MIT License
6.23k stars 2.41k forks source link

07_NaturalLanguageProcessing_04_SkipGram: Question on Line 272 on -sim #122

Closed ychong closed 6 years ago

ychong commented 6 years ago

Apologies for the simple question:

For Line 272, why do we multiply sim matrix by negative?

Why -sim[j, :]?

nfmcclure commented 6 years ago

Hi Thanks for the question. I'm just starting on updating the book and code for a version 2. When I get to chapter 7, I'll add an explanation.

nfmcclure commented 6 years ago

I'll add this to the notebook and next version of the book, but here is an explanation now:

The argsort() method sorts from least to greatest. Since we have a similarity matrix, we want to sort from greatest similarity to least similarity. If we take the negative of all the numbers before sorting, that will sort the indices of the numbers in the correct order. I hope that helps!

ychong commented 6 years ago

Thanks for the clarification and reply Nick.

Really appreciate it.

On Wed, Mar 21, 2018 at 10:17 PM, Nick notifications@github.com wrote:

Hi Thanks for the question. I'm just starting on updating the book and code for a version 2. When I get to chapter 7, I'll add an explanation.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/nfmcclure/tensorflow_cookbook/issues/122#issuecomment-374952157, or mute the thread https://github.com/notifications/unsubscribe-auth/ACHU98l1VrWkuyzTyT5Xhln8TuIIU77Iks5tgmDlgaJpZM4SAyHp .