python - Tensorflow InvalidArgumentError: indekser [[40]]=2000 0 er ikke i [[0, 20000)

Indlæg af Hanne Mølgaard Plasc

Problem



Jeg var runnig denne kode (https://github.com/monkut/tensorflow\_chatbot hovedkode i execute.py) på min Windows7 med python 3.5 og tensorflow r0.12 cpu og en fejl opstod efter kun 300 trin. Så forsøgte jeg at ændre ordforrådsstørrelsen til 30000 og sætte en checkpiont hvert 100 trin. Med 1 lag på 128 enheder opstod fejlen efter 3900 trin og med 3 lag på 256 enheder forekom det efter 5400 trin.
Hvilken slags fejl er det? Er der en måde at løse det på? [8]


Fejl:


>> Mode : train

Preparing data in working\_dir/
Creating vocabulary working\_dir/vocab20000.enc from data/train.enc
  processing line 100000
>> Full Vocabulary Size : 45408
>>>> Vocab Truncated to: 20000
Creating vocabulary working\_dir/vocab20000.dec from data/train.dec
  processing line 100000
>> Full Vocabulary Size : 44271
>>>> Vocab Truncated to: 20000
Tokenizing data in data/train.enc
  tokenizing line 100000
Tokenizing data in data/train.dec
  tokenizing line 100000
Tokenizing data in data/test.enc
Creating 3 layers of 256 units.
Created model with fresh parameters.
Reading development and training data (limit: 0).
  reading data line 100000
global step 300 learning rate 0.5000 step-time 3.34 perplexity 377.45
  eval: bucket 0 perplexity 96.25
  eval: bucket 1 perplexity 210.94
  eval: bucket 2 perplexity 267.86
  eval: bucket 3 perplexity 365.77
Traceback (most recent call last):
  File "C:Python35 64libsite-packages	ensorflowpythonclientsession.py", l
ine 1021, in \_do\_call
    return fn(*args)
  File "C:Python35 64libsite-packages	ensorflowpythonclientsession.py", l
ine 1003, in \_run\_fn
    status, run\_metadata)
  File "C:Python35 64libcontextlib.py", line 66, in \_\_exit\_\_
    next(self.gen)
  File "C:Python35 64libsite-packages	ensorflowpythonframeworkerrors\_impl
.py", line 469, in raise\_exception\_on\_not\_ok\_status
    pywrap\_tensorflow.TF\_GetCode(status))
tensorflow.python.framework.errors\_impl.InvalidArgumentError: indices[40] = 2000
0 is not in [0, 20000)
         [**Node: model\_with\_buckets/sequence\_loss\_3/sequence\_loss\_by\_example/sam
pled\_softmax\_loss\_28/embedding\_lookup\_1 = Gather[Tindices=DT\_INT64, Tparams=DT\_F
LOAT, \_class=["loc:@proj\_b"], validate\_indices=true, \_device="/job:localhost/rep
lica:0/task:0/cpu:0"](proj\_b/read, model\_with\_buckets/sequence\_loss\_3/sequence\_l
oss\_by\_example/sampled\_softmax\_loss\_28/concat)**]

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "execute.py", line 352, in <module>
    train()
  File "execute.py", line 180, in train
    target\_weights, bucket\_id, False)
  File "C:UsersАдминистраторDownloads	ensorflow\_chatbot-master (1)	ensorflo
w\_chatbot-masterseq2seq\_model.py", line 230, in step
    outputs = session.run(output\_feed, input\_feed)
  File "C:Python35 64libsite-packages	ensorflowpythonclientsession.py", l
ine 766, in run
    run\_metadata\_ptr)
  File "C:Python35 64libsite-packages	ensorflowpythonclientsession.py", l
ine 964, in \_run
    feed\_dict\_string, options, run\_metadata)
  File "C:Python35 64libsite-packages	ensorflowpythonclientsession.py", l
ine 1014, in \_do\_run
    target\_list, options, run\_metadata)
  File "C:Python35 64libsite-packages	ensorflowpythonclientsession.py", l
ine 1034, in \_do\_call
    raise type(e)(node\_def, op, message)
tensorflow.python.framework.errors\_impl.InvalidArgumentError: indices[40] = 2000
0 is not in [0, 20000)
         [**Node: model\_with\_buckets/sequence\_loss\_3/sequence\_loss\_by\_example/sam
pled\_softmax\_loss\_28/embedding\_lookup\_1 = Gather[Tindices=DT\_INT64, Tparams=DT\_F
LOAT, \_class=["loc:@proj\_b"], validate\_indices=true, \_device="/job:localhost/rep
lica:0/task:0/cpu:0"](proj\_b/read, model\_with\_buckets/sequence\_loss\_3/sequence\_l
oss\_by\_example/sampled\_softmax\_loss\_28/concat)**]

Caused by op 'model\_with\_buckets/sequence\_loss\_3/sequence\_loss\_by\_example/sample
d\_softmax\_loss\_28/embedding\_lookup\_1', defined at:
  File "execute.py", line 352, in <module>
    train()
  File "execute.py", line 148, in train
    model = create\_model(sess, False)
  File "execute.py", line 109, in create\_model
    gConfig['learning\_rate\_decay\_factor'], forward\_only=forward\_only)
  File "C:UsersАдминистраторDownloads	ensorflow\_chatbot-master (1)	ensorflo
w\_chatbot-masterseq2seq\_model.py", line 158, in \_\_init\_\_
    softmax\_loss\_function=softmax\_loss\_function)
  File "C:Python35 64libsite-packages	ensorflowpythonopsseq2seq.py", line
 1130, in model\_with\_buckets
    softmax\_loss\_function=softmax\_loss\_function))
  File "C:Python35 64libsite-packages	ensorflowpythonopsseq2seq.py", line
 1058, in sequence\_loss
    softmax\_loss\_function=softmax\_loss\_function))
  File "C:Python35 64libsite-packages	ensorflowpythonopsseq2seq.py", line
 1022, in sequence\_loss\_by\_example
    crossent = softmax\_loss\_function(logit, target)
  File "C:UsersАдминистраторDownloads	ensorflow\_chatbot-master (1)	ensorflo
w\_chatbot-masterseq2seq\_model.py", line 101, in sampled\_loss
    self.target\_vocab\_size)
  File "C:Python35 64libsite-packages	ensorflowpythonops
n.py", line 1412
, in sampled\_softmax\_loss
    name=name)
  File "C:Python35 64libsite-packages	ensorflowpythonops
n.py", line 1184
, in \_compute\_sampled\_logits
    all\_b = embedding\_ops.embedding\_lookup(biases, all\_ids)
  File "C:Python35 64libsite-packages	ensorflowpythonopsembedding\_ops.py"
, line 110, in embedding\_lookup
    validate\_indices=validate\_indices)
  File "C:Python35 64libsite-packages	ensorflowpythonopsgen\_array\_ops.py"
, line 1293, in gather
    validate\_indices=validate\_indices, name=name)
  File "C:Python35 64libsite-packages	ensorflowpythonframeworkop\_def\_libr
ary.py", line 759, in apply\_op
    op\_def=op\_def)
  File "C:Python35 64libsite-packages	ensorflowpythonframeworkops.py", li
ne 2240, in create\_op
    original\_op=self.\_default\_original\_op, op\_def=op\_def)
  File "C:Python35 64libsite-packages	ensorflowpythonframeworkops.py", li
ne 1128, in \_\_init\_\_
    self.\_traceback = \_extract\_stack()

InvalidArgumentError (see above for traceback): indices[40] = 20000 is not in [0
, 20000)
         [**Node: model\_with\_buckets/sequence\_loss\_3/sequence\_loss\_by\_example/sam
pled\_softmax\_loss\_28/embedding\_lookup\_1 = Gather[Tindices=DT\_INT64, Tparams=DT\_F
LOAT, \_class=["loc:@proj\_b"], validate\_indices=true, \_device="/job:localhost/rep
lica:0/task:0/cpu:0"](proj\_b/read, model\_with\_buckets/sequence\_loss\_3/sequence\_l
oss\_by\_example/sampled\_softmax\_loss\_28/concat)**]

Bedste reference


Notationen [) betyder Inklusiv Eksklusiv i interval notation.
[ betyder inklusive dette nummer . ( betyder at udelukke dette nummer.
Det samme gælder for de rigtige parenteser og parentes dvs. ] & ). For eksempel [0,20000)
betyder fra Zero inklusive til 20000 ikke inklusive. Brackets betyder 'Ja indeholde denne' parentes betyder 'nej, lad ikke gå helt op til dette nummer'

Andre referencer 1


Det ser ud til at bruge virtualenv og tensorflow-gpu 0.12.0 løser problemet for mig.