其他分享
首页 > 其他分享> > 增加正则项Regularization to Prevent Overfitting

增加正则项Regularization to Prevent Overfitting

作者:互联网

1,

model_l1 = tf.estimator.LinearClassifier(
feature_columns=base_columns + crossed_columns,
optimizer=tf.train.FtrlOptimizer(
learning_rate=0.1,
l1_regularization_strength=10.0,
l2_regularization_strength=0.0))

model_l1.train(train_inpf)

results = model_l1.evaluate(test_inpf)
clear_output()
for key in sorted(results):
print('%s: %0.2f' % (key, results[key]))

 

2,

model_l2 = tf.estimator.LinearClassifier(
feature_columns=base_columns + crossed_columns,
optimizer=tf.train.FtrlOptimizer(
learning_rate=0.1,
l1_regularization_strength=0.0,
l2_regularization_strength=10.0))

model_l2.train(train_inpf)

results = model_l2.evaluate(test_inpf)
clear_output()
for key in sorted(results):
print('%s: %0.2f' % (key, results[key]))

标签:Overfitting,Prevent,Regularization,results,train,l2,key,model,columns
来源: https://www.cnblogs.com/augustone/p/10506117.html