在TensorFlow-slim
的源代码中,创建其损失函数时标明了一个端点:
def clone_fn(batch_queue): """通过创建network_fn的多个克隆来实现数据并行性。""" images, labels = batch_queue.dequeue() logits, end_points = network_fn(images) ############################# # 指定损失函数 # ############################# if 'AuxLogits' in end_points: slim.losses.softmax_cross_entropy( end_points['AuxLogits'], labels, label_smoothing=FLAGS.label_smoothing, weight=0.4, scope='aux_loss') slim.losses.softmax_cross_entropy( logits, labels, label_smoothing=FLAGS.label_smoothing, weight=1.0) return end_points
来源:https://github.com/tensorflow/models/blob/master/slim/train_image_classifier.py#L471-L477
我的想法是,有多个相同的网络在不同的机器上进行训练,最后变量和参数会被平均以合并成一个网络(这是正确的吗?)。但我不太明白在这种情况下端点的作用是什么,因为我以为network_fn应该只产生用于预测的logits。end_points有什么用途?
回答:
在这种情况下,endpoints
只是跟踪模型的不同输出。例如,AuxLogits
包含了logits。