keras icon indicating copy to clipboard operation
keras copied to clipboard

Question about Tensorflow compatibility

Open chenmoneygithub opened this issue 1 year ago • 6 comments

Hi team!

I have a few questions about the Tensorflow compatibility, could you help clarify?

  1. In future Tensorflow versions (I assume it's starting from 2.16), will TF depend on Keras 3 instead of tf-keras?
  2. If 1 is correct, does it mean tf-keras will be a frozen package?
  3. Will from tensorflow import keras or tf.keras keep working? This is not the best practice, but MLflow (the package I am maintaining now) needs to keep the backward compatibility, so from tensorflow import keras will be the simplest solution.

Thanks for the help!

Best, Chen Money

chenmoneygithub avatar Dec 27 '23 21:12 chenmoneygithub

from my experiences (i am porting over my models to keras 3)

  1. tf works as is, i think the minimum required tf version is ~2.12
  2. tf.keras and keras cannot be imported at the same time (meaning that your code should either do all tf.keras or all keras.)
  3. you can still mix tf code in keras3 (eg. calling tf.boolean_mask or some other ops). only tf.keras need to be changed

haohuanw avatar Dec 29 '23 18:12 haohuanw

@chenmoneygithub - Thanks for raising this issue.

  1. Starting in TF 2.16, Keras 3 will be installed with TensorFlow. But TF will also remain compatible with tf-keras and users can switch via env. variable TF_USE_LEGACY_KERAS=1 and installing tf-keras pip package.

does it mean tf-keras will be a frozen package?

  1. We will continue to release a tf-keras version that's aligned with TensorFlow version for users wanting to use Keras 2.

  2. from tensorflow import keras will use Keras 3 from TF 2.16 unless the env variable is set, which will then import tf_keras package (keras 2).

sampathweb avatar Dec 31 '23 08:12 sampathweb

@sampathweb Thanks for the clarification!

chenmoneygithub avatar Jan 03 '24 18:01 chenmoneygithub

Hi @chenmoneygithub ,

Could you please confirm whether we can mark it as resolved ?

SuryanarayanaY avatar Jan 26 '24 15:01 SuryanarayanaY

@SuryanarayanaY Yes, by the way could you make sure this information is included somewhere? thanks!

chenmoneygithub avatar Jan 26 '24 19:01 chenmoneygithub

Hi @chenmoneygithub ,

This is already documented here. Could you please check and confirm if still missing any info there. Thanks!

SuryanarayanaY avatar Jan 31 '24 05:01 SuryanarayanaY

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.

github-actions[bot] avatar Apr 26 '24 01:04 github-actions[bot]

This issue was closed because it has been inactive for 28 days. Please reopen if you'd like to work on this further.

github-actions[bot] avatar May 10 '24 01:05 github-actions[bot]

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

google-ml-butler[bot] avatar May 10 '24 01:05 google-ml-butler[bot]