Comments (6)
Inspecting the code for TextVectorization
(https://github.com/keras-team/keras/blob/master/keras/layers/preprocessing/text_vectorization.py#L491) and deserialize_keras_object
(https://github.com/keras-team/keras/blob/master/keras/saving/serialization_lib.py#L392), I see that there is no way the proper logic for deserializing the split function will run. The deserialization code looks for if module_objects is not None:, but TextVectorization.from_config()
doesn't pass a module_objects
parameter to deserialize_keras_object
, so that code block doesn't execute.
As a workaround, I extended the tf.keras.layers.TextVectorization
class with:
class PatchedTextVectorization(tf.keras.layers.TextVectorization):
@classmethod
def from_config(cls, config):
if not isinstance(config["standardize"], str):
config["standardize"] = tf.keras.saving.deserialize_keras_object(config["standardize"])
if not isinstance(config["split"], str):
config["split"] = tf.keras.saving.deserialize_keras_object(config["split"], module_objects = [])
return cls(**config)
Cloning an instance of PatchedTextVectorization
constructed with the split function works fine. You can see I shoehorned module_objects = []
into its invocation of tf.keras.saving.deserialize_keras_object
.
from tf-keras.
@sachinprasadhs,
I was able to reproduce the issue on tensorflow v2.14, v2.15. Kindly find the gist of it here.
from tf-keras.
@rlcauvin , From TensorFlow 2.16, Keras 3 will be the backend for tf.keras, I see this is working fine with Keras 3, that should fix your issue, is there any specific reason you're using tf.keras with 2.15?
You can use tensorflow 2.15 and Keras 3 as well.
install tensorflow first and then install keras 3.
from tf-keras.
This issue is stale because it has been open for 14 days with no activity. It will be closed if no further activity occurs. Thank you.
from tf-keras.
Thank you, @sachinprasadhs. Using !pip install -U keras
to install Keras 3 worked for that isolated case. However, I want to use tensorflow_decision_forests
. Unfortunately, import tensorflow_decision_forests as tfdf
results in the error below. Please see the modified Google Colab notebook for the full code.
[/usr/local/lib/python3.10/dist-packages/tensorflow_decision_forests/keras/core.py](https://localhost:8080/#) in <module>
75 # tf>1.12
---> 76 import keras.src.engine.data_adapter as data_adapter
77 except ImportError:
ModuleNotFoundError: No module named 'keras.src.engine'
During handling of the above exception, another exception occurred:
ModuleNotFoundError Traceback (most recent call last)
3 frames
[<ipython-input-3-b4486e63aff0>](https://localhost:8080/#) in <cell line: 1>()
----> 1 import tensorflow_decision_forests as tfdf
2 import tensorflow as tf
3 from typing import Text
[/usr/local/lib/python3.10/dist-packages/tensorflow_decision_forests/__init__.py](https://localhost:8080/#) in <module>
62 check_version.check_version(__version__, compatible_tf_versions)
63
---> 64 from tensorflow_decision_forests import keras
65 from tensorflow_decision_forests.component import py_tree
66 from tensorflow_decision_forests.component.builder import builder
[/usr/local/lib/python3.10/dist-packages/tensorflow_decision_forests/keras/__init__.py](https://localhost:8080/#) in <module>
51 from typing import Callable, List
52
---> 53 from tensorflow_decision_forests.keras import core
54 from tensorflow_decision_forests.keras import wrappers
55
[/usr/local/lib/python3.10/dist-packages/tensorflow_decision_forests/keras/core.py](https://localhost:8080/#) in <module>
77 except ImportError:
78 # tf<=1.12
---> 79 import keras.engine.data_adapter as data_adapter
80 get_data_handler = data_adapter.get_data_handler
81
ModuleNotFoundError: No module named 'keras.engine'
from tf-keras.
Fixed in this commit! Thank you, closing this issue.
from tf-keras.
Related Issues (20)
- Error while importing tf_keras HOT 11
- shape issue for y_pred for a custom made loss function HOT 3
- UNIMPLEMENTED: Cast string to float is not supported; CANCELLED: Function was cancelled before it was started HOT 3
- TextVectorization: output_mode={multi_hot, count} promise int arrays but output floats
- Mirrored strategy model.load_weights() failure HOT 2
- sparse_categorical_crossentropy with ignore_class=-1 makes loss to `nan` HOT 3
- Importing `tf_keras` to use Keras 2 in TensorFlow 2.16 fails HOT 9
- Addition of Reflect Padding Functionality for tf.keras Convolutional Layers HOT 2
- AttributeError: module 'tf_keras.backend' has no attribute 'logsumexp' HOT 6
- Custom Keras RNN with constants changes constants shape when saving HOT 3
- ValueError: (F1Score|FBetaScore) expects 2D inputs with shape (batch_size, output_dim). HOT 8
- LSTM - different outputs for same weights across CPU and GPU, when using float32 + tf-keras + NVIDIA A100 HOT 4
- RetinaNet with custom backbone and custom dataset HOT 3
- IntegerLookup with XLA Compilation Fails to Enable JIT in TensorFlow 2.16.1 and Keras 3.2.1 HOT 3
- conda-forge release HOT 1
- Failed to build Python package due to missing layer/experimental build HOT 2
- TF-Keras mixed precision training leads to autograph errors HOT 4
- Showing warning just after importing tf_keras HOT 4
- Error loading the trained model. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tf-keras.