greta-dev / greta

simple and scalable statistical modelling in R
https://greta-stats.org
Other
518 stars 63 forks source link

A note on keras 2 and keras 3 #633

Open njtierney opened 1 month ago

njtierney commented 1 month ago

Note that TF 2.16 will be using Keras3 not Keras2.

We currently use TF 15.1 for dev greta (https://github.com/njtierney/greta/tree/tf2-poke-tf-fun).

However, it means we will eventually need to use keras3 inside greta, or will need to set some special flags for keras 2 implementation for TF2 >= 2.16 - reading from the above post on TF 2.16, it might need to be something like:

To continue using Keras 2 with TensorFlow 2.16+:

Install tf-keras vía pip install tf-keras~=2.16 Switch tf.keras to use Keras 2 (tf-keras), by setting environment variable TF_USE_LEGACY_KERAS=1 directly or in your Python program by doing import os;os.environ["TF_USE_LEGACY_KERAS"]=”1”. Please note that this needs to be set before importing TensorFlow and will set it for all packages in your Python runtime program.