Coder Social home page Coder Social logo

Comments (9)

theraghavjuneja avatar theraghavjuneja commented on April 27, 2024 2

Instead of input length:10 I used input_shape=(10,) to reproduce the same effect. It worked for me. But when u read the documentation u won't find anything like input_shape you would only find input_length.

from tensorflow.

theraghavjuneja avatar theraghavjuneja commented on April 27, 2024

Ok I tried converting the input_length to input_shape of(10,) formulating what it was trying to say in the documentation. (On searching I found this). But shouldn't that be updated in documentation as well?

from tensorflow.

MujahidMalik819061 avatar MujahidMalik819061 commented on April 27, 2024

ValueError: Unrecognized keyword arguments passed to Embedding: {'input_length': 10}
how to solve this error

from tensorflow.

Venkat6871 avatar Venkat6871 commented on April 27, 2024

Hi @theraghavjuneja ,
Sorry for the delay, I tried to run your code on Colab using TF v2.16.1, nightly and faced the same issue. Please find the gist here for reference.

Thank you!

from tensorflow.

Venkat6871 avatar Venkat6871 commented on April 27, 2024

Hi @theraghavjuneja ,
The error occurs because the Embedding layer in TensorFlow 2.x does not have an input_length argument. This argument was removed in version 2.0.0 of TensorFlow.

To fix this error, you need to remove the input_length argument from the Embedding layer. The input_length argument is used to specify the maximum length of the input sequences. However, in TensorFlow 2.x, the Embedding layer automatically infers the input length from the input data. Please find the gist here for reference.

from tensorflow.

TomBerton avatar TomBerton commented on April 27, 2024

Instead of input length:10 I used input_shape=(10,) to reproduce the same effect. It worked for me. But when u read the documentation u won't find anything like input_shape you would only find input_length.

I created an LSTM-based sequential model for text generation. I updated my keras to 3.1.1 and had the same issue. Using input_shape=(25,) worked for my model. Thanks.

from tensorflow.

akramIOT avatar akramIOT commented on April 27, 2024

Hi @TomBerton : I am hitting this same issue with TF==2.16 version for my CNN Word2Vector Embeddings

Define the CNN model

model = Sequential()
model.add(Embedding(vocab_size, 100, weights=[embedding_matrix],input_length=max_length, trainable=False))
model.add(Conv1D(128, 5, activation='relu'))

(DS) akram_personal@AKRAMs-MacBook-Pro DS_2024 %
(DS) akram_personal@AKRAMs-MacBook-Pro DS_2024 % pip list | grep Tensroflow
(DS) akram_personal@AKRAMs-MacBook-Pro DS_2024 %
(DS) akram_personal@AKRAMs-MacBook-Pro DS_2024 % pip list | grep Tensorflow
]% (DS) akram_personal@AKRAMs-MacBook-Pro DS_2024 % ]
zsh: command not found: ]
(DS) akram_personal@AKRAMs-MacBook-Pro DS_2024 % pip list | grep tensorflow
tensorflow 2.16.1
tensorflow-datasets 4.9.4
tensorflow-estimator 2.12.0
tensorflow-io-gcs-filesystem 0.36.0
tensorflow-metadata 1.14.0
(DS) akram_personal@AKRAMs-MacBook-Pro DS_2024 %
(DS) akram_personal@AKRAMs-MacBook-Pro DS_2024 % pip list | grep keras
keras 3.1.1
tf_keras 2.16.0
(DS) akram_personal@AKRAMs-MacBook-Pro DS_2024 %

from tensorflow.

akramIOT avatar akramIOT commented on April 27, 2024

Hi @TomBerton : I am hitting this same issue with TF==2.16 version for my CNN Word2Vector Embeddings

Define the CNN model

model = Sequential() model.add(Embedding(vocab_size, 100, weights=[embedding_matrix],input_length=max_length, trainable=False)) model.add(Conv1D(128, 5, activation='relu'))

(DS) akram_personal@AKRAMs-MacBook-Pro DS_2024 % (DS) akram_personal@AKRAMs-MacBook-Pro DS_2024 % pip list | grep Tensroflow (DS) akram_personal@AKRAMs-MacBook-Pro DS_2024 % (DS) akram_personal@AKRAMs-MacBook-Pro DS_2024 % pip list | grep Tensorflow ]% (DS) akram_personal@AKRAMs-MacBook-Pro DS_2024 % ] zsh: command not found: ] (DS) akram_personal@AKRAMs-MacBook-Pro DS_2024 % pip list | grep tensorflow tensorflow 2.16.1 tensorflow-datasets 4.9.4 tensorflow-estimator 2.12.0 tensorflow-io-gcs-filesystem 0.36.0 tensorflow-metadata 1.14.0 (DS) akram_personal@AKRAMs-MacBook-Pro DS_2024 % (DS) akram_personal@AKRAMs-MacBook-Pro DS_2024 % pip list | grep keras keras 3.1.1 tf_keras 2.16.0 (DS) akram_personal@AKRAMs-MacBook-Pro DS_2024 %

(DS) akram_personal@AKRAMs-MacBook-Pro DS_2024 % python CNN_WordVec.py
Traceback (most recent call last):
File "/Users/akram_personal/AKRAM_CODE_FOLDER/DS_EXERCISES/DS_2024/CNN_WordVec.py", line 114, in
model.add(Embedding(vocab_size, 100, weights=[embedding_matrix], trainable=False))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/anaconda3/envs/DS/lib/python3.11/site-packages/keras/src/layers/core/embedding.py", line 81, in init
super().init(**kwargs)
File "/opt/anaconda3/envs/DS/lib/python3.11/site-packages/keras/src/layers/layer.py", line 264, in init
raise ValueError(
ValueError: Unrecognized keyword arguments passed to Embedding: {'weights': [array([[0., 0., 0., ..., 0., 0., 0.],
[0., 0., 0., ..., 0., 0., 0.],
[0., 0., 0., ..., 0., 0., 0.],
...,
[0., 0., 0., ..., 0., 0., 0.],
[0., 0., 0., ..., 0., 0., 0.],
[0., 0., 0., ..., 0., 0., 0.]])]}
(DS) akram_personal@AKRAMs-MacBook-Pro DS_2024 %

from tensorflow.

google-ml-butler avatar google-ml-butler commented on April 27, 2024

Are you satisfied with the resolution of your issue?
Yes
No

from tensorflow.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.