for name in avg_values:
avg_values[name] += reader.get_tensor(name) / num_checkpoints
latest_step = int(checkpoints_path[-1].split("-")[-1])
return _create_checkpoint_from_variables(
avg_values,
output_dir,
After Change
tf.logging.info("Listing variables...")
new_variables = {}
for i, checkpoint_path in enumerate(checkpoints_path):
tf.logging.info("Loading checkpoint %s" % checkpoint_path)
variables = get_checkpoint_variables(checkpoint_path)
for name, value in six.iteritems(variables):
if _variable_is_trainable(name, value):
scaled_value = value / num_checkpoints
if name in new_variables:
new_variables[name] += scaled_value
else:
new_variables[name] = scaled_value
elif i + 1 == num_checkpoints: // Take non trainable variables from the last checkpoint.
new_variables[name] = value
return _create_checkpoint_from_variables(
new_variables,
output_dir,