代码之家  ›  专栏  ›  技术社区  ›  rawwar

Adam优化器在TensorFlow中返回的第一个值是什么

  •  2
  • rawwar  · 技术社区  · 6 年前

    我正在使用TensorFlow创建两层dnn。我使用adamoptimer作为优化程序。下面是我的代码

    pred_raw = create_feedforward_nn_model(x, weights, biases)
    pred = tf.round(tf.nn.sigmoid(pred_raw))
    cost = tf.reduce_mean(tf.nn.sigmoid_cross_entropy_with_logits(labels=pred, logits=y))
    train_op = tf.train.AdamOptimizer(learning_rate).minimize(cost)
    

    当我这样做的时候 seession.run train_op 它返回两个值,我知道第二个值是损失,但是这里的第一个值是什么。我看过很多教程,但在大多数教程中,他们都忽略了第一个值,如下面所示

    _,loss = sess.run([train_op, cost],={x: batch_features, y: batch_labels})
    
    1 回复  |  直到 6 年前
        1
  •  2
  •   Tim    6 年前

    mnist/mechanics 在下面 检查状态 您可以找到以下行:

    自从 train_op 是一个没有输出值的操作,返回的元组中的对应元素为none,因此被丢弃。然而,如果模型在训练过程中发生偏离,则损失张量的值可能会变为NaN,因此我们捕获该值用于测井。