YOLOv3-tensorflow不收敛

时间:2018-11-22 04:10:04

标签: python tensorflow deep-learning loss-function yolo

我正在尝试在tensorflow中实现YOLOv3,我从在线存储库获得了帮助,并成功地将darknet权重转换为tensorflow并进行了推理。 现在,我正在尝试使用已实现的here的YOLO损失来训练模型。

我正在使用以下代码段来这样做:

    with tf.name_scope('Loss_and_Detect'):
        yolo_loss = compute_loss(output, y_true, anchors, config.num_classes, print_loss=False)
        tf.summary.scalar('YOLO_loss', yolo_loss)
        variables = tf.trainable_variables()

        # Variables to be optimized by train_op if the pre-trained darknet-53 is used as is
        if config.pre_train:
            variables = variables[312:] # Get the weights after the 52nd conv-layer (darknet-53)

                  # 5e-4 as used in the paper
        l2_loss = config.weight_decay * tf.add_n([tf.nn.l2_loss(tf.cast(v, dtype=tf.float32)) for v in variables]) 
        loss = yolo_loss + l2_loss
        tf.summary.scalar('L2_loss', l2_loss)
        tf.summary.scalar('Total_loss', loss)

    # Define an optimizer for minimizing the computed loss
    with tf.name_scope('Optimizer'):
        update_ops = tf.get_collection(tf.GraphKeys.UPDATE_OPS)
        with tf.control_dependencies(update_ops):
            optimizer = tf.train.AdamOptimizer(learning_rate=learning_rate)

    update_ops = tf.get_collection(tf.GraphKeys.UPDATE_OPS)

    with tf.control_dependencies(update_ops):
        train_op = optimizer.minimize(loss=loss, global_step=global_step, var_list=variables)

问题是我的YOLO_loss停留在大约7-8,而L2_loss继续增加。

Here is a snapshot of the tensorboard with learning rate 1e-6 with exponential decay applied to it.(decay_rate=0.8)

我无法弄清楚我丢失/做错了什么。 任何帮助表示赞赏。

0 个答案:

没有答案