-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
prime->[update] optimzation.py and modeling.py for tensorflow 2x.
MOTIVATION PR to resolve `AttributeError: module 'tensorflow._api.v2.train' has no attribute 'Optimizer'` `optimization.py`: - change `tf.train.Optimizer` -> `tf.compat.v1.train.Optimizer` due to tensorflow 2x. src: [ https://www.tensorflow.org/api_docs/python/tf/compat/v1 ] `modeling.py`: (due to changes made in `optimization.py`) - add `@tf.function` decorator above `get_shape_list(...)` due to eager execution enabled by default in tensorflow 2x. src: [ https://www.tensorflow.org/guide/function ] - change `tf.get_variable` -> `tf.compat.v1.get_variable`. - change `tf.variable_score` -> `tf.compat.v1.variable_score`. - change `tf.truncated_normal_initializer` -> `tf.compat.v1.truncated_normal_initializer`. - change `tf.assert_less_equal` -> `tf.compat.v1.assert_less_equal`. - change `tf.get_variable_scope` -> `tf.compat.v1.get_variable_scope`. src: [ https://www.tensorflow.org/api_docs/python/tf/compat/v1 ] - change `tf.layers.dense` -> `tf.keras.layers.Dense` due to Keras 3. - change `tf.contrib.layers.layer_norm` -> `tf.keras.layers.LayerNormalization`. src: [ https://www.tensorflow.org/api_docs/python/tf/keras/layers/Dense ] src: [ https://stackoverflow.com/a/62357941/11492382 ] CONFIGURATION software : Windows 11 Home [21H2]. WSL version 2.2.4.0; openSUSE tumbleweed 20240629 hardware : 64-bit operating system, x64-based processor conda_env : cudnn 8.9.7.29 conda-forge python 3.12.2 conda-forge tensorflow 2.16.1 conda-forge Reported-by : Майкл Шодеке Signed-off-by: Майкл Шодеке
- Loading branch information
Showing
2 changed files
with
48 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters