TannerGilbert / Tutorials

Code for some of my articles
https://gilberttanner.com/
MIT License
561 stars 631 forks source link

InvalidArgumentError: indices[15,0] = 10000 is not in [0, 10000) #19

Closed MohammadHeydari closed 4 years ago

MohammadHeydari commented 4 years ago

When I run predictions = model.predict([user, book_data]) these lines of errors shows up.

InvalidArgumentError                      Traceback (most recent call last)
<ipython-input-39-5ab1f94396a9> in <module>
      4 user = np.array([1 for i in range(len(book_data))])
      5 
----> 6 predictions = model.predict([user, book_data])
      7 predictions = np.array([a[0] for a in predictions])
      8 

~/anaconda3/lib/python3.7/site-packages/keras/engine/training.py in predict(self, x, batch_size, verbose, steps, callbacks, max_queue_size, workers, use_multiprocessing)
   1460                                             verbose=verbose,
   1461                                             steps=steps,
-> 1462                                             callbacks=callbacks)
   1463 
   1464     def train_on_batch(self, x, y,

~/anaconda3/lib/python3.7/site-packages/keras/engine/training_arrays.py in predict_loop(model, f, ins, batch_size, verbose, steps, callbacks)
    322             batch_logs = {'batch': batch_index, 'size': len(batch_ids)}
    323             callbacks._call_batch_hook('predict', 'begin', batch_index, batch_logs)
--> 324             batch_outs = f(ins_batch)
    325             batch_outs = to_list(batch_outs)
    326             if batch_index == 0:

~/anaconda3/lib/python3.7/site-packages/tensorflow/python/keras/backend.py in __call__(self, inputs)
   3074 
   3075     fetched = self._callable_fn(*array_vals,
-> 3076                                 run_metadata=self.run_metadata)
   3077     self._call_fetch_callbacks(fetched[-len(self._fetches):])
   3078     return nest.pack_sequence_as(self._outputs_structure,

~/anaconda3/lib/python3.7/site-packages/tensorflow/python/client/session.py in __call__(self, *args, **kwargs)
   1437           ret = tf_session.TF_SessionRunCallable(
   1438               self._session._session, self._handle, args, status,
-> 1439               run_metadata_ptr)
   1440         if run_metadata:
   1441           proto_data = tf_session.TF_GetBuffer(run_metadata_ptr)

~/anaconda3/lib/python3.7/site-packages/tensorflow/python/framework/errors_impl.py in __exit__(self, type_arg, value_arg, traceback_arg)
    526             None, None,
    527             compat.as_text(c_api.TF_Message(self.status.status)),
--> 528             c_api.TF_GetCode(self.status.status))
    529     # Delete the underlying status object from memory otherwise it stays alive
    530     # as there is a reference to status from this from the traceback due to

InvalidArgumentError: indices[15,0] = 10000 is not in [0, 10000)
     [[{{node Book-Embedding_7/embedding_lookup}}]]
TannerGilbert commented 4 years ago

Duplicate of #1