TensorFlow-Examples icon indicating copy to clipboard operation
TensorFlow-Examples copied to clipboard

Evaluation words error

Open Mustyy opened this issue 7 years ago • 4 comments

I changed the eval words to some of my own I end up with this error, any idea why?


KeyError Traceback (most recent call last) in () 8 9 # Testing data ---> 10 x_test = np.array([word2id[w] for w in eval_words]) 11 12 average_loss = 0

in (.0) 8 9 # Testing data ---> 10 x_test = np.array([word2id[w] for w in eval_words]) 11 12 average_loss = 0

KeyError: 'economic'

Mustyy avatar Nov 08 '18 20:11 Mustyy

My environment is python:3.6.6, tensorflow-gpu:1.12 2 reasone may lead to this, i found. First you should check the key's type, actually i found the orginal key type is "bytes", like b"five". If this is true, change your key to byte type. Next, maybe word2id doesn't have this key, you should print out that to see what it has.

kalinlau avatar Dec 19 '18 11:12 kalinlau

thanks mate, it works.

wmaa0002 avatar Jan 30 '19 09:01 wmaa0002

@wmaa0002 how did you fix this?

Traceback (most recent call last):
  File "word2vec.py", line 160, in <module>
    x_test = np.array([word2id[w] for w in eval_words])
  File "word2vec.py", line 160, in <listcomp>
    x_test = np.array([word2id[w] for w in eval_words])
KeyError: 'five'

The script has:

# Words for testing.
x_test = np.array([word2id[w] for w in eval_words])

LinuxPersonEC avatar Nov 09 '20 20:11 LinuxPersonEC

Still getting this with TF 2.6.2, CUDA11.0

Traceback (most recent call last):
  File "word2vec.py", line 158, in <module>
    for step in xrange(1, num_steps + 1):
NameError: name 'xrange' is not defined

LinuxPersonEC avatar Nov 16 '21 17:11 LinuxPersonEC