tf2.0 tf.contrib.framework.get_global_setp()
时间: 2024-05-06 13:20:42 浏览: 106
get_global_step() is a function in the tf.contrib.framework module in TensorFlow 1.x that returns the global step tensor. The global step tensor is a variable that keeps track of the number of training steps that have been executed.
However, in TensorFlow 2.0, the tf.contrib framework has been deprecated and replaced by other APIs, including the Keras API. Therefore, get_global_step() is no longer available in TensorFlow 2.0. Instead, you can use the Keras callback tf.keras.callbacks.LearningRateScheduler, which takes a global step (epoch) as an argument and adjusts the learning rate accordingly.
Alternatively, you can create a global step variable using the tf.Variable() function and increment it manually in your training loop. For example:
```
global_step = tf.Variable(0, trainable=False, dtype=tf.int64)
for img, label in dataset:
# Perform training steps here
global_step.assign_add(1)
```
阅读全文