[tensorflow定义loss]分类模型
交叉熵:
loss = tf.losses.softmax_cross_entropy(logits=dnn, onehot_labels=label_ph)
正确率(不参与bp):
acc = tf.reduce_mean(tf.cast(tf.equal(tf.argmax(dnn, axis=-1), tf.argmax(label_ph, axis=-1)), dtype=tf.float32))
优化器:
lr = 0.01
optimizer = tf.train.GradientDescentOptimizer(learning_rate=lr)
train_op = optimizer.minimize(loss)