Open DynTechieBibin opened 1 month ago
ImportError: cannot import name 'TokenAndPositionEmbedding' from 'keras_nlp.layers'
tensorflow Version: 2.17.0
keras Version: 3.5.0
keras-nlp Version: 0.0.2
from keras_nlp.layers import TokenAndPositionEmbedding, TransformerEncoder, TransformerDecoder
decoder_embedding = TokenAndPositionEmbedding(len(target_tokenizer.word_index) + 1, sequence_len, embed_dim)(decoder_input)
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"
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).
keras_hub.layers
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"