如何解决Tensorflow DNNclassifier精度低
您好,我是tensorflow的新手,我正尝试在此数据集https://drive.google.com/file/d/1OFnnDExSCliNyPkSMLkqNrSy5UuSLFXl/view?usp=sharing上使用DNN分类器
以下代码是输入函数
def input_fun(features,labels,training=True,batch_size=256):
ds=tf.data.Dataset.from_tensor_slices((dict(features),labels))
if training:
ds.shuffle(1000).repeat()
return ds.batch(batch_size)
这是功能列
my_feature_columns = []
for key in train.keys():
my_feature_columns.append(tf.feature_column.numeric_column(key=key))
print(my_feature_columns)
模型的创建
classifier=tf.estimator.DNNClassifier(
feature_columns=my_feature_columns,hidden_units=[70,10],n_classes=7)
最后训练代码
classifier.train(
input_fn=lambda: input_fun(train,train_y),steps=5000)
所以问题是训练模型时只走了一步
INFO:tensorflow:Done calling model_fn.
INFO:tensorflow:Create CheckpointSaverHook.
INFO:tensorflow:Graph was finalized.
INFO:tensorflow:Running local_init_op.
INFO:tensorflow:Done running local_init_op.
INFO:tensorflow:Calling checkpoint listeners before saving checkpoint 0...
INFO:tensorflow:Saving checkpoints for 0 into /tmp/tmpa_n0egjm/model.ckpt.
INFO:tensorflow:Calling checkpoint listeners after saving checkpoint 0...
INFO:tensorflow:loss = 31.256369,step = 0
INFO:tensorflow:Calling checkpoint listeners before saving checkpoint 100...
INFO:tensorflow:Saving checkpoints for 100 into /tmp/tmpa_n0egjm/model.ckpt.
INFO:tensorflow:Calling checkpoint listeners after saving checkpoint 100...
INFO:tensorflow:Loss for final step: 2.4960964.
<tensorflow_estimator.python.estimator.canned.dnn.DNNClassifierV2 at 0x7fd373e45c18>
并且在评估准确性时简直太可怕了,不胜感激
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。