求解为什么auc是0.5
Created by: starsblinking
两种写法,第一种auc正常,可以训练到0.9+;第二种auc自始自终都是0.5,求解原因啊
第一种(auc正常): binary_predict = fluid.layers.fc( input=fc3, size=2, act="softmax", param_attr=fluid.ParamAttr(initializer=fluid.initializer.Normal( scale=1 / math.sqrt(fc3.shape[1]))), ) cost = fluid.layers.cross_entropy(input=binary_predict, label=inputs[1]) avg_cost = fluid.layers.mean(cost)
auc_var, batch_auc_var, auc_stat_list = fluid.layers.auc(input=binary_predict, label=inputs[1]) optimizer.minimize(avg_cost) #-----------------------------------------
第二种写法(auc恒为0.5): fc4 = fluid.layers.fc( input=fc3, size=1, act=None, param_attr=fluid.ParamAttr(initializer=fluid.initializer.Normal( scale=1 / math.sqrt(fc3.shape[1]))), ) predict = fluid.layers.sigmoid(fc4) cast_label = fluid.layers.cast(inputs[1], dtype='float32') cost = fluid.layers.log_loss(input=predict, label=cast_label) avg_cost = fluid.layers.mean(cost) ones = fluid.layers.ones_like(predict) binary_predict = fluid.layers.concat( input=[fluid.layers.elementwise_sub(ones, predict), predict], axis=1)
auc_var, batch_auc_var, auc_stat_list = fluid.layers.auc(input=binary_predict, label=inputs[1]) optimizer.minimize(avg_cost) #-----------------------------------------
哪里不对呢?感觉这两种计算binary_predict和predict的方式是基本等效的>.< paddle1.8.3, train_from_dataset, cpu异步训练