当训练tensorflow联合学习模型时,为什么我会看到本地时期的输出?
我正在培训一种张量子流联合学习模型。我看不到时期的输出。详细信息如下:
split = 4
NUM_ROUNDS = 5
NUM_EPOCHS = 10
BATCH_SIZE = 2
PREFETCH_BUFFER = 5
for round_num in range(1, NUM_ROUNDS+1):
state, tff_metrics = iterative_process.next(state, federated_train_data)
print('round {:2d}, metrics{}'.format(round_num,tff_metrics['train'].items()))
eval_model = create_keras_model()
eval_model.compile(optimizer=optimizers.Adam(learning_rate=client_lr),
loss=losses.BinaryCrossentropy(),
metrics=[tf.keras.metrics.Accuracy()])
#tff.learning.assign_weights_to_keras_model(eval_model, state.model)
state.model.assign_weights_to(eval_model)
ev_result = eval_model.evaluate(x_val, y_val, verbose=2)
train_metrics = tff_metrics['train']
for name, value in tff_metrics['train'].items():
tf.summary.scalar(name,value, step=round_num)
tff_val_acc.append(ev_result[1])
tff_val_loss.append(ev_result[0])
我的输出外观如下:
round 1, metrics=odict_items([('accuracy', 0.0), ('loss', 1.2104079)])
1/1 - 1s - loss: 0.7230 - accuracy: 0.0000e+00 - 1s/epoch - 1s/step
round 2, metrics=odict_items([('accuracy', 0.0007142857), ('loss', 1.2233553)])
1/1 - 1s - loss: 0.6764 - accuracy: 0.0000e+00 - 646ms/epoch - 646ms/step
round 3, metrics=odict_items([('accuracy', 0.0), ('loss', 1.1939998)])
1/1 - 1s - loss: 0.6831 - accuracy: 0.0000e+00 - 635ms/epoch - 635ms/step
round 4, metrics=odict_items([('accuracy', 0.0), ('loss', 1.2829995)])
1/1 - 1s - loss: 0.6830 - accuracy: 0.0000e+00 - 641ms/epoch - 641ms/step
round 5, metrics=odict_items([('accuracy', 0.0), ('loss', 1.2051892)])
1/1 - 1s - loss: 0.7135 - accuracy: 0.0000e+00 - 621ms/epoch - 621ms/step
每回合后,全局模型的这些值是否吗?如何绘制曲线以确保100个时期的全局模型的验证准确性(10轮,每轮10个局部时期)? (不在张板中)
I am training a tensorflow federated learning model. I cannot see the output of epochs. Details are as follows:
split = 4
NUM_ROUNDS = 5
NUM_EPOCHS = 10
BATCH_SIZE = 2
PREFETCH_BUFFER = 5
for round_num in range(1, NUM_ROUNDS+1):
state, tff_metrics = iterative_process.next(state, federated_train_data)
print('round {:2d}, metrics{}'.format(round_num,tff_metrics['train'].items()))
eval_model = create_keras_model()
eval_model.compile(optimizer=optimizers.Adam(learning_rate=client_lr),
loss=losses.BinaryCrossentropy(),
metrics=[tf.keras.metrics.Accuracy()])
#tff.learning.assign_weights_to_keras_model(eval_model, state.model)
state.model.assign_weights_to(eval_model)
ev_result = eval_model.evaluate(x_val, y_val, verbose=2)
train_metrics = tff_metrics['train']
for name, value in tff_metrics['train'].items():
tf.summary.scalar(name,value, step=round_num)
tff_val_acc.append(ev_result[1])
tff_val_loss.append(ev_result[0])
And my output looks as follows:
round 1, metrics=odict_items([('accuracy', 0.0), ('loss', 1.2104079)])
1/1 - 1s - loss: 0.7230 - accuracy: 0.0000e+00 - 1s/epoch - 1s/step
round 2, metrics=odict_items([('accuracy', 0.0007142857), ('loss', 1.2233553)])
1/1 - 1s - loss: 0.6764 - accuracy: 0.0000e+00 - 646ms/epoch - 646ms/step
round 3, metrics=odict_items([('accuracy', 0.0), ('loss', 1.1939998)])
1/1 - 1s - loss: 0.6831 - accuracy: 0.0000e+00 - 635ms/epoch - 635ms/step
round 4, metrics=odict_items([('accuracy', 0.0), ('loss', 1.2829995)])
1/1 - 1s - loss: 0.6830 - accuracy: 0.0000e+00 - 641ms/epoch - 641ms/step
round 5, metrics=odict_items([('accuracy', 0.0), ('loss', 1.2051892)])
1/1 - 1s - loss: 0.7135 - accuracy: 0.0000e+00 - 621ms/epoch - 621ms/step
Are these values for global model after each round? How can I plot the curves for validation accuracy of the global model for the 100 epochs (10 rounds, 10 local epochs per round)? (Not in tensorboard)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
通常,在联合学习中,客户端执行的是服务器看不到的本地计算。在这种情况下,服务器(或美国建模者)仅查看本地培训的结果(而不是单个时期)。
是的,日志记录是陈述是每一轮后全球模型的训练和验证指标的组合。请注意,联邦学习中的培训指标具有微妙的特殊性。
这些行是培训指标,并且由代码生成:
验证指标是由Keras打印的,这些记录语句:
正在由此行打印:
tff_val_acc
和tff_val_loss
列表应具有验证度量值,按圆数索引。使用诸如matplotlib
之类的库( https://matplotlib.org/ )绘制这些曲线的选项?Generally in federated learning the client is performing local computation not visible to the server. In this case, the server (or us modelers) only see the the result of that local training (not the individual epochs).
Yes, the logging is statements are a mix of both training and validation metrics of the global model after each round. Note that the training metrics in federated learning have a subtle peculiarity.
these lines are the training metrics, and are being produced by the code:
The validation metrics are being printed by Keras, these logging statements:
are being printed by this line:
The
tff_val_acc
andtff_val_loss
lists should have the validation metric values, indexed by round number. Using a library such asmatplotlib
(https://matplotlib.org/) could be an option for plotting these curves?