增加正则项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]))

上一篇:UVA 674 Coin Change 换硬币 经典dp入门题


下一篇:Vue.js基础(更新学习笔记ing...)