def add_loss_summaries(total_loss, loss, regul_losses_collection_key,
                       name_prefix="", summaries_collection_key=None,
                       exp_moving_avg=0.9, ema_num_updates=None):
    # Compute the moving average of all individual losses and the total loss.
    loss_averages = tf.train.ExponentialMovingAverage(exp_moving_avg,
                                                      ema_num_updates,
                                                      name='moving_avg')
    other_losses = tf.get_collection(regul_losses_collection_key)

    # Attach a scalar summmary to all individual losses and the total loss;
    # do the same for the averaged version of the losses.
    # Name each loss as '(raw)' and name the moving average version of the loss
    # as the original loss name.

    # Only add total loss, if it has more than one loss...
    if len(other_losses) > 0 and total_loss is not None:
        loss_averages_op = loss_averages.apply(
            [total_loss] + [loss] + other_losses)
        summ_name = "- Loss & var loss/" + name_prefix
        get_summary("scalar", summ_name, loss_averages.average(total_loss),
                    summaries_collection_key)
        get_summary("scalar", summ_name + ' (raw)', total_loss,
                    summaries_collection_key)
    elif total_loss is not None:
        loss_averages_op = loss_averages.apply([loss] + other_losses)
    else:
        loss_averages_op = loss_averages.apply([loss])

    # For tflearn wrapper visibility
    summ_name = "- Loss/" + name_prefix
    get_summary("scalar", summ_name, loss_averages.average(loss),
                summaries_collection_key)
    get_summary("scalar", summ_name + ' (raw)', loss, summaries_collection_key)

    for wdl in other_losses:
        # No prefix, we store every variable into their own scope
        summ_name = wdl.op.name
        get_summary("scalar", summ_name, loss_averages.average(wdl),
                    summaries_collection_key)
        get_summary("scalar", summ_name + ' (raw)', wdl,
                    summaries_collection_key)

    return loss_averages_op
add_loss_summaries.
dataset/ETHPy150Open tflearn/tflearn/tflearn/summaries.py/add_loss_summaries