Closed ghost closed 1 month ago
PR to resolve AttributeError: module 'tensorflow._api.v2.train' has no attribute 'Optimizer'
optimization.py:
optimization.py
tf.train.Optimizer
tf.compat.v1.train.Optimizer
modeling.py: (due to changes made in optimization.py)
modeling.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 ]
@tf.function
get_shape_list(...)
change tf.get_variable -> tf.compat.v1.get_variable.
tf.get_variable
tf.compat.v1.get_variable
change tf.variable_score -> tf.compat.v1.variable_score.
tf.variable_score
tf.compat.v1.variable_score
change tf.truncated_normal_initializer -> tf.compat.v1.truncated_normal_initializer.
tf.truncated_normal_initializer
tf.compat.v1.truncated_normal_initializer
change tf.assert_less_equal -> tf.compat.v1.assert_less_equal.
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 ]
tf.get_variable_scope
tf.compat.v1.get_variable_scope
change tf.layers.dense -> tf.keras.layers.Dense due to Keras 3.
tf.layers.dense
tf.keras.layers.Dense
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 ]
tf.contrib.layers.layer_norm
tf.keras.layers.LayerNormalization
Reported-by : Майкл Шодеке Signed-off-by: Майкл Шодеке
MOTIVATION
PR to resolve AttributeError: module 'tensorflow._api.v2.train' has no attribute 'Optimizer'
optimization.py
: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 inoptimization.py
)add
@tf.function
decorator aboveget_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
Reported-by : Майкл Шодеке Signed-off-by: Майкл Шодеке