Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TokenAndPositionEmbedding missing from keras_nlp.layers #1867

Open
DynTechieBibin opened this issue Sep 24, 2024 · 1 comment
Open

TokenAndPositionEmbedding missing from keras_nlp.layers #1867

DynTechieBibin opened this issue Sep 24, 2024 · 1 comment
Assignees

Comments

@DynTechieBibin
Copy link

DynTechieBibin commented Sep 24, 2024

ImportError: cannot import name 'TokenAndPositionEmbedding' from 'keras_nlp.layers'

Packages installed (Windows OS)

tensorflow Version: 2.17.0

keras Version: 3.5.0

keras-nlp Version: 0.0.2

Code:

from keras_nlp.layers import TokenAndPositionEmbedding, TransformerEncoder, TransformerDecoder

decoder_embedding = TokenAndPositionEmbedding(len(target_tokenizer.word_index) + 1, sequence_len, embed_dim)(decoder_input)

Tried:

pip install keras-nlp==0.15.1
Collecting keras-nlp==0.15.1

Using cached keras_nlp-0.15.1-py3-none-any.whl.metadata (6.7 kB)

Requirement already satisfied: absl-py in \python\python312\lib\site-packages (from keras-nlp==0.15.1) (2.1.0)

Requirement already satisfied: numpy in \python\python312\lib\site-packages (from keras-nlp==0.15.1) (1.26.4)

Requirement already satisfied: packaging in \python\python312\lib\site-packages (from keras-nlp==0.15.1) (24.1)

Requirement already satisfied: regex in \python\python312\lib\site-packages (from keras-nlp==0.15.1) (2024.9.11)

Requirement already satisfied: rich in \python\python312\lib\site-packages (from keras-nlp==0.15.1) (13.8.1)

Collecting kagglehub (from keras-nlp==0.15.1)
Using cached kagglehub-0.3.0-py3-none-any.whl.metadata (21 kB)

INFO: pip is looking at multiple versions of keras-nlp to determine which version is compatible with other requirements. This could take a while.

ERROR: Could not find a version that satisfies the requirement tensorflow-text; platform_system != "Darwin" (from keras-nlp) (from versions: none)

ERROR: No matching distribution found for tensorflow-text; platform_system != "Darwin"

@SamanehSaadat
Copy link
Member

Hi @DynTechieBibin

We recently merged KerasCV and KerasNLP into KerasHub. Could you try importing it from keras_hub.layers? I believe it should work (code ref).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants