-
Notifications
You must be signed in to change notification settings - Fork 19.5k
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
Keras 2 <> Keras 3 incompatibilities #18467
Comments
I checked out the issue for converting keras.io examples to |
Hello, I wanted to ask about the plans to add a KerasRaggedTensor to Keras Core. I would be very interested to have this feature, just to feed the Tensors of shape (batch, None, C, F, ...) to a keras model. I understand that keras backend ops can not support ragged operations across platforms but simply to pass a ragged Tensor to layers as input and output and extract splits and values would be super helpful. |
We might support However if you're just looking to have a dynamic data dimension, then you can do it just by:
In general it is possible to handle any workflow using rectangular tensors. RaggedTensors are a convenience but not a blocker. |
No idea how it is UX or performance wise, but torch recently added https://pytorch.org/torchrec/torchrec.sparse.html “jagged tensor” instead of “ragged” |
For backend agnostic, this may reasonable change (but quite big change). What about the ---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
[<ipython-input-7-694b2dd940b3>](https://localhost:8080/#) in <cell line: 14>()
12 model.compile(optimizer='adam', loss='mse')
13 _ = model(np.random.rand(96, 96))
---> 14 model.save_weights('model.h5')
1 frames
[/usr/local/lib/python3.10/dist-packages/keras/src/models/model.py](https://localhost:8080/#) in save_weights(self, filepath, overwrite)
371 """
372 if not str(filepath).endswith(".weights.h5"):
--> 373 raise ValueError(
374 "The filename must end in `.weights.h5`. "
375 f"Received: filepath={filepath}"
ValueError: The filename must end in `.weights.h5`. Received: filepath=model.h5 In the built-in model, the keras.applications.EfficientNetV2B0(
include_top=True,
weights="imagenet",
input_tensor=None,
input_shape=None,
pooling=None,
classes=1000,
classifier_activation="softmax",
include_preprocessing=True,
)
output
Downloading data from https://storage.googleapis.com/tensorflow/keras-applications/efficientnet_v2/efficientnetv2-b0.h5
29403144/29403144 ━━━━━━━━━━━━━━━━━━━━ 0s 0us/step
<Functional name=efficientnetv2-b0, built=True> |
I was told over at tensorflow that Keras 3 will not support nested input dictionaries. While I don't understand why that support was removed, that's definitely an incompatibility that's worth mentioning here. |
`tf-nightly` was pinned at #6655 due to Keras 3 release. `Keras 2 <> Keras incompatibilities` (keras-team/keras#18467) are impacting the Graph plugin and Hparams plugin, since the two plugins are not being actively developed and updating the code to be Keras 3 compatible is non-trivial, enforce using Keras 2 for the time being. Note that `tf-nightly` is not compatible with `tf-keras` and needs to be used with `tf-keras-nightly` instead. Googlers, see b/309503942 for more context. Tested internally: cl/582334596 #oncall
Hello, we are using Update: I found yes. Use tf-keras instead. |
Is there any particular reason why AlphaDropout layer is removed? |
Same question here. SELU needs AlphaDropout. |
The |
@fchollet May I ask what the consideration is for "Layer names and variable names can no longer contain the / character."? I have to make many efforts to convert my old checkpoints and weights for keras-3 compatibility. UPDATE: The current temporary workaround for me is to wrap the |
There is no more method |
We do not support Tensorflow >2.15 since Keras 3.x brings several breaking changes keras-team/keras#18467
We do not support Tensorflow >2.15 since Keras 3.x brings several breaking changes keras-team/keras#18467
We do not support Tensorflow >2.15 since Keras 3.x brings several breaking changes keras-team/keras#18467
We do not support Tensorflow >2.15 since Keras 3.x brings several breaking changes keras-team/keras#18467
We do not support Tensorflow >2.15 since Keras 3.x brings several breaking changes keras-team/keras#18467
We do not support Tensorflow >2.15 since Keras 3.x brings several breaking changes keras-team/keras#18467
We do not support Tensorflow >2.15 since Keras 3.x brings several breaking changes keras-team/keras#18467
We do not support Tensorflow >2.15 since Keras 3.x brings several breaking changes keras-team/keras#18467
We do not support Tensorflow >2.15 since Keras 3.x brings several breaking changes keras-team/keras#18467
I suspect something may have changed re dynamic binding of methods or some other horrible pythonic thing.If I create a Sequential model:
And when I subclass Sequential, I cannot call the parent method:
As a side note, please could these sorts of changes be included in formal API documentation? It seems most of the documentation on the Keras site is in the style of small tutorial examples, and a github issue to list breaking changes isn't the best way to navigate what needs to be done, especially when dealing with a scripting language and there is no compiler to help us out. Being able to navigate something like Doxygen and including breaking changes there would be a much better way of seeing hat has changed. Thanks |
Additionally, it seems that RNNs don't support Cells with multiple inputs anymore. Really sad. The "sequences" parameter (note plural) in the |
We do not support Tensorflow >2.15 since Keras 3.x brings several breaking changes keras-team/keras#18467
While trying to run TCN with Keras 3 philipperemy/keras-tcn#256 (issue opened by another person) I found, that while Sequential model in earlier versions allows to get/set Weights in build method, it's not the case with Keras 3 (there is error that numpy is not available ("numpy() is only available when eager execution is enabled"), while previously this was not a case, also functional model somehow has no this problem) see example in first comment tensorflow/addons#2869 (the error is with tensorflow addons master branch, which is not completely ported to Keras 3, but still demonstrates a problem) additionally: support for causal padding is removed from SeparableConv1D in Keras 3, so it's more difficult to add SeparableConv1D to TCN |
Hello, |
The list of behavior changes between the old tf.keras and Keras 3 with TF backend is missing the redefinition of the Old version: https://github.com/keras-team/keras/blob/v2.15.0/keras/backend.py#L5924 I find it worrying that such a breaking change has been made without mentioning it anywhere. The only mention of this change I could find was this issue on the TF GitHub pages, which noted that the documentation for The problem is that this change silently alters the output of every model that uses |
We do not support Tensorflow >2.15 since Keras 3.x brings several breaking changes keras-team/keras#18467
Keras 3 is a major new release. It features a number of cleanups and modernizations of Keras which leads to number of breaking changes compared to Keras 2.
The list below is exhaustive to the best of our knowledge.
A small number of items are likely to affect you (
jit_compile
default value change, TF SavedModel support changes, usage oftf.Variable
as layer attributes). The majority are very niche. All APIs that were removed were dropped due to extremely low usage.Behavior differences between old
tf.keras
and Keras 3 (with TF backend)compat.v1
APIs are gone (deprecated in 2019). In the case ofexperimental
APIs, usually those are APIs that have already moved to a permanent namespace long ago (e.g. the contents oftf.keras.layers.experimental.preprocessing
is now atkeras.layers
, since 2021), so just update the import path to the up-to-date location.jit_compile=True
by default -- this might not work with all TF ops, so with some custom models/layers you might have setjit_compile=False
if you see an XLA related error.model.save()
is no longer supported (note: you can usetf.save_model.save(model)
instead)keras.models.load_model()
is no longer supported (note: you can usekeras.layers.TFSMLayer(filepath, call_endpoint="serving_default")
to reload any TF SavedModel as a Keras layer)Model()
can no longer be passed deeply nested inputs/outputs (nested more than 1 level deep, e.g. lists of lists of tensors)tf.keras
, TF autograph is enabled by default on thecall()
method of custom layers. In Keras 3, it is not. This means you may have to usecond
ops if you're using control flow, or alternatively you can decorate yourcall()
method with@tf.function
.keras.ops
.evaluate()
method does not return individual output losses anymore -> use themetrics
argument in compile to track them/
character.RaggedTensor
support. We may add it back later.output_a
andoutput_b
, oldtf.keras
adds<output_a>_loss
,<output_b>_loss
and so on to metrics. Keras 3 doesn't add them to metrics and needs to be done them to the output metrics by explicitly providing them inmetrics
list of individual outputs.tf.Variable
objects assigned to aLayer
are not tracked as part ofweights
. Fix: useself.add_weight()
method or use akeras.Variable
instead.None
entries are not allowed as part of nested (e.g. list/tuples) tensor arguments inLayer.call()
, nor as part ofcall()
return values.add_loss()
is removed (you can still useadd_loss()
inside thecall()
method of a layer/model).Layer
attributesmetrics
,dynamic
are removedconstants
arg in RNN layers is removed (remnant of Theano, ~0 usage)time_major
arg in RNN layers is removed (~0 usage)reset_metrics
argument frommodel.*_on_batch
methods (~0 usage)RadialConstraint
constraint object is removed (~0 usage)Present in Keras 3 standalone but will work when accessing Keras 3 via the new
tf.keras
backend.random_normal
AlphaDropout
layer is removedThresholdedReLU
layer is removed (subsumed byReLU
)RandomHeight
/RandomWidth
layers are removed (better useRandomZoom
)The text was updated successfully, but these errors were encountered: