File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed
Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change 1212# See the License for the specific language governing permissions and
1313# limitations under the License.
1414"""Imports keras 2."""
15+ import os
16+
17+ from absl import logging
1518import tensorflow as tf
1619
20+ if 'TF_USE_LEGACY_KERAS' not in os .environ :
21+ # Make sure we are using Keras 2.
22+ os .environ ['TF_USE_LEGACY_KERAS' ] = '1'
23+ elif os .environ ['TF_USE_LEGACY_KERAS' ] not in ('true' , 'True' , '1' ):
24+ logging .warning (
25+ 'TF_USE_LEGACY_KERAS is set to %s, which will not use Keras 2. Tensorflow'
26+ ' Transform is only compatible with Keras 2. Please set'
27+ ' TF_USE_LEGACY_KERAS=1.' ,
28+ os .environ ['TF_USE_LEGACY_KERAS' ],
29+ )
30+
1731version_fn = getattr (tf .keras , 'version' , None )
1832if version_fn and version_fn ().startswith ('3.' ):
1933 # `tf.keras` points to `keras 3`, so use `tf_keras` package
You can’t perform that action at this time.
0 commit comments