привет, я пытаюсь использовать одну и ту же программу составления резюме в разных файлах. Это псевдокод моего кода. train_summary_writer сохраняет значения только один раз в начале
globals.py
import tensorflow as tf
def initialize_train_summary_writer(x_train_path):
global train_summary_writer
train_summary_writer = tf.summary.create_file_writer(x_train_path)
train.py
initialize_train_summary_writer(summary_store_path)
for file,label in traindata:
if num_iterations == epoch_iterations:
val_mean_loss = trainer_eager.eval_data_on_val_set(valid_data, net,steps_per_valid_epoch,global_step_, batch_, time_)
# training the network and storing summaries goes here
special_eval_for_network.py
def eval_data_on_val_set(valid_data, net,steps_per_valid_epoch,global_step_, batch_, time_):
for img, label in valid_data:
# apply on network and add to summary
# calculate epoch_seg_loss_avg
with globals.train_summary_writer.as_default():
tf.summary.scalar("avg_loss", epoch_seg_loss_avg, step=global_step)