请问为什么这么写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) binary_predict = fluid.layers.concat( input=[fluid.layers.elementwise_sub(fluid.layers.ceil(predict), 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的方式是一样的,而且第二种比第一种自然。第一种还得再去取出binary_predict的第2列来作为预测的ctr保存起来(顺便问一句怎么取呢。。。) paddle1.8.3, train_from_dataset, cpu异步训练