Any workaround to fix word embedding look-up error for keras model?












0












$begingroup$


I am working with character level cnn model for sentence classification, and I used keras framework to build my model. However, model compilation was good, but when I tried to fit my model I faced following embedding lookup error:



Train on 10240 samples, validate on 1284 samples
Epoch 1/30
---------------------------------------------------------------------------
InvalidArgumentError Traceback (most recent call last)
<ipython-input-57-15a1aa414e1a> in <module>
1 history_char= model_char.fit(x_train,y_train,epochs=num_epochs, batch_size=batch_size,
----> 2 validation_data=(x_val,y_val))
3
4 # model_char.fit(x_train,y_train,epochs=10, batch_size=64, validation_data=(x_val, y_val))

~AppDataLocalContinuumanaconda3libsite-packageskerasenginetraining.py in fit(self, x, y, batch_size, epochs, verbose, callbacks, validation_split, validation_data, shuffle, class_weight, sample_weight, initial_epoch, steps_per_epoch, validation_steps, **kwargs)
1037 initial_epoch=initial_epoch,
1038 steps_per_epoch=steps_per_epoch,
-> 1039 validation_steps=validation_steps)
1040
1041 def evaluate(self, x=None, y=None,

~AppDataLocalContinuumanaconda3libsite-packageskerasenginetraining_arrays.py in fit_loop(model, f, ins, out_labels, batch_size, epochs, verbose, callbacks, val_f, val_ins, shuffle, callback_metrics, initial_epoch, steps_per_epoch, validation_steps)
197 ins_batch[i] = ins_batch[i].toarray()
198
--> 199 outs = f(ins_batch)
200 outs = to_list(outs)
201 for l, o in zip(out_labels, outs):

~AppDataLocalContinuumanaconda3libsite-packageskerasbackendtensorflow_backend.py in __call__(self, inputs)
2713 return self._legacy_call(inputs)
2714
-> 2715 return self._call(inputs)
2716 else:
2717 if py_any(is_tensor(x) for x in inputs):

~AppDataLocalContinuumanaconda3libsite-packageskerasbackendtensorflow_backend.py in _call(self, inputs)
2673 fetched = self._callable_fn(*array_vals, run_metadata=self.run_metadata)
2674 else:
-> 2675 fetched = self._callable_fn(*array_vals)
2676 return fetched[:len(self.outputs)]
2677

~AppDataLocalContinuumanaconda3libsite-packagestensorflowpythonclientsession.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)

~AppDataLocalContinuumanaconda3libsite-packagestensorflowpythonframeworkerrors_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[120,0] = 516 is not in [0, 70)
[[{{node embedding_14/embedding_lookup}}]]


here is basic architecture of keras model (screenshot):



enter image description here









share







New contributor




beyond_inifinity is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.







$endgroup$

















    0












    $begingroup$


    I am working with character level cnn model for sentence classification, and I used keras framework to build my model. However, model compilation was good, but when I tried to fit my model I faced following embedding lookup error:



    Train on 10240 samples, validate on 1284 samples
    Epoch 1/30
    ---------------------------------------------------------------------------
    InvalidArgumentError Traceback (most recent call last)
    <ipython-input-57-15a1aa414e1a> in <module>
    1 history_char= model_char.fit(x_train,y_train,epochs=num_epochs, batch_size=batch_size,
    ----> 2 validation_data=(x_val,y_val))
    3
    4 # model_char.fit(x_train,y_train,epochs=10, batch_size=64, validation_data=(x_val, y_val))

    ~AppDataLocalContinuumanaconda3libsite-packageskerasenginetraining.py in fit(self, x, y, batch_size, epochs, verbose, callbacks, validation_split, validation_data, shuffle, class_weight, sample_weight, initial_epoch, steps_per_epoch, validation_steps, **kwargs)
    1037 initial_epoch=initial_epoch,
    1038 steps_per_epoch=steps_per_epoch,
    -> 1039 validation_steps=validation_steps)
    1040
    1041 def evaluate(self, x=None, y=None,

    ~AppDataLocalContinuumanaconda3libsite-packageskerasenginetraining_arrays.py in fit_loop(model, f, ins, out_labels, batch_size, epochs, verbose, callbacks, val_f, val_ins, shuffle, callback_metrics, initial_epoch, steps_per_epoch, validation_steps)
    197 ins_batch[i] = ins_batch[i].toarray()
    198
    --> 199 outs = f(ins_batch)
    200 outs = to_list(outs)
    201 for l, o in zip(out_labels, outs):

    ~AppDataLocalContinuumanaconda3libsite-packageskerasbackendtensorflow_backend.py in __call__(self, inputs)
    2713 return self._legacy_call(inputs)
    2714
    -> 2715 return self._call(inputs)
    2716 else:
    2717 if py_any(is_tensor(x) for x in inputs):

    ~AppDataLocalContinuumanaconda3libsite-packageskerasbackendtensorflow_backend.py in _call(self, inputs)
    2673 fetched = self._callable_fn(*array_vals, run_metadata=self.run_metadata)
    2674 else:
    -> 2675 fetched = self._callable_fn(*array_vals)
    2676 return fetched[:len(self.outputs)]
    2677

    ~AppDataLocalContinuumanaconda3libsite-packagestensorflowpythonclientsession.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)

    ~AppDataLocalContinuumanaconda3libsite-packagestensorflowpythonframeworkerrors_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[120,0] = 516 is not in [0, 70)
    [[{{node embedding_14/embedding_lookup}}]]


    here is basic architecture of keras model (screenshot):



    enter image description here









    share







    New contributor




    beyond_inifinity is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.







    $endgroup$















      0












      0








      0





      $begingroup$


      I am working with character level cnn model for sentence classification, and I used keras framework to build my model. However, model compilation was good, but when I tried to fit my model I faced following embedding lookup error:



      Train on 10240 samples, validate on 1284 samples
      Epoch 1/30
      ---------------------------------------------------------------------------
      InvalidArgumentError Traceback (most recent call last)
      <ipython-input-57-15a1aa414e1a> in <module>
      1 history_char= model_char.fit(x_train,y_train,epochs=num_epochs, batch_size=batch_size,
      ----> 2 validation_data=(x_val,y_val))
      3
      4 # model_char.fit(x_train,y_train,epochs=10, batch_size=64, validation_data=(x_val, y_val))

      ~AppDataLocalContinuumanaconda3libsite-packageskerasenginetraining.py in fit(self, x, y, batch_size, epochs, verbose, callbacks, validation_split, validation_data, shuffle, class_weight, sample_weight, initial_epoch, steps_per_epoch, validation_steps, **kwargs)
      1037 initial_epoch=initial_epoch,
      1038 steps_per_epoch=steps_per_epoch,
      -> 1039 validation_steps=validation_steps)
      1040
      1041 def evaluate(self, x=None, y=None,

      ~AppDataLocalContinuumanaconda3libsite-packageskerasenginetraining_arrays.py in fit_loop(model, f, ins, out_labels, batch_size, epochs, verbose, callbacks, val_f, val_ins, shuffle, callback_metrics, initial_epoch, steps_per_epoch, validation_steps)
      197 ins_batch[i] = ins_batch[i].toarray()
      198
      --> 199 outs = f(ins_batch)
      200 outs = to_list(outs)
      201 for l, o in zip(out_labels, outs):

      ~AppDataLocalContinuumanaconda3libsite-packageskerasbackendtensorflow_backend.py in __call__(self, inputs)
      2713 return self._legacy_call(inputs)
      2714
      -> 2715 return self._call(inputs)
      2716 else:
      2717 if py_any(is_tensor(x) for x in inputs):

      ~AppDataLocalContinuumanaconda3libsite-packageskerasbackendtensorflow_backend.py in _call(self, inputs)
      2673 fetched = self._callable_fn(*array_vals, run_metadata=self.run_metadata)
      2674 else:
      -> 2675 fetched = self._callable_fn(*array_vals)
      2676 return fetched[:len(self.outputs)]
      2677

      ~AppDataLocalContinuumanaconda3libsite-packagestensorflowpythonclientsession.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)

      ~AppDataLocalContinuumanaconda3libsite-packagestensorflowpythonframeworkerrors_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[120,0] = 516 is not in [0, 70)
      [[{{node embedding_14/embedding_lookup}}]]


      here is basic architecture of keras model (screenshot):



      enter image description here









      share







      New contributor




      beyond_inifinity is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.







      $endgroup$




      I am working with character level cnn model for sentence classification, and I used keras framework to build my model. However, model compilation was good, but when I tried to fit my model I faced following embedding lookup error:



      Train on 10240 samples, validate on 1284 samples
      Epoch 1/30
      ---------------------------------------------------------------------------
      InvalidArgumentError Traceback (most recent call last)
      <ipython-input-57-15a1aa414e1a> in <module>
      1 history_char= model_char.fit(x_train,y_train,epochs=num_epochs, batch_size=batch_size,
      ----> 2 validation_data=(x_val,y_val))
      3
      4 # model_char.fit(x_train,y_train,epochs=10, batch_size=64, validation_data=(x_val, y_val))

      ~AppDataLocalContinuumanaconda3libsite-packageskerasenginetraining.py in fit(self, x, y, batch_size, epochs, verbose, callbacks, validation_split, validation_data, shuffle, class_weight, sample_weight, initial_epoch, steps_per_epoch, validation_steps, **kwargs)
      1037 initial_epoch=initial_epoch,
      1038 steps_per_epoch=steps_per_epoch,
      -> 1039 validation_steps=validation_steps)
      1040
      1041 def evaluate(self, x=None, y=None,

      ~AppDataLocalContinuumanaconda3libsite-packageskerasenginetraining_arrays.py in fit_loop(model, f, ins, out_labels, batch_size, epochs, verbose, callbacks, val_f, val_ins, shuffle, callback_metrics, initial_epoch, steps_per_epoch, validation_steps)
      197 ins_batch[i] = ins_batch[i].toarray()
      198
      --> 199 outs = f(ins_batch)
      200 outs = to_list(outs)
      201 for l, o in zip(out_labels, outs):

      ~AppDataLocalContinuumanaconda3libsite-packageskerasbackendtensorflow_backend.py in __call__(self, inputs)
      2713 return self._legacy_call(inputs)
      2714
      -> 2715 return self._call(inputs)
      2716 else:
      2717 if py_any(is_tensor(x) for x in inputs):

      ~AppDataLocalContinuumanaconda3libsite-packageskerasbackendtensorflow_backend.py in _call(self, inputs)
      2673 fetched = self._callable_fn(*array_vals, run_metadata=self.run_metadata)
      2674 else:
      -> 2675 fetched = self._callable_fn(*array_vals)
      2676 return fetched[:len(self.outputs)]
      2677

      ~AppDataLocalContinuumanaconda3libsite-packagestensorflowpythonclientsession.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)

      ~AppDataLocalContinuumanaconda3libsite-packagestensorflowpythonframeworkerrors_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[120,0] = 516 is not in [0, 70)
      [[{{node embedding_14/embedding_lookup}}]]


      here is basic architecture of keras model (screenshot):



      enter image description here







      deep-learning keras





      share







      New contributor




      beyond_inifinity is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.










      share







      New contributor




      beyond_inifinity is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.








      share



      share






      New contributor




      beyond_inifinity is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      asked 4 mins ago









      beyond_inifinitybeyond_inifinity

      11




      11




      New contributor




      beyond_inifinity is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.





      New contributor





      beyond_inifinity is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






      beyond_inifinity is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






















          0






          active

          oldest

          votes











          Your Answer





          StackExchange.ifUsing("editor", function () {
          return StackExchange.using("mathjaxEditing", function () {
          StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
          StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
          });
          });
          }, "mathjax-editing");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "557"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });






          beyond_inifinity is a new contributor. Be nice, and check out our Code of Conduct.










          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdatascience.stackexchange.com%2fquestions%2f47767%2fany-workaround-to-fix-word-embedding-look-up-error-for-keras-model%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          beyond_inifinity is a new contributor. Be nice, and check out our Code of Conduct.










          draft saved

          draft discarded


















          beyond_inifinity is a new contributor. Be nice, and check out our Code of Conduct.













          beyond_inifinity is a new contributor. Be nice, and check out our Code of Conduct.












          beyond_inifinity is a new contributor. Be nice, and check out our Code of Conduct.
















          Thanks for contributing an answer to Data Science Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          Use MathJax to format equations. MathJax reference.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdatascience.stackexchange.com%2fquestions%2f47767%2fany-workaround-to-fix-word-embedding-look-up-error-for-keras-model%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Erzsébet Schaár

          Ponta tanko

          Facebook