我正在查看这篇 Tensorflow 文章的源代码,该文章讨论了如何创建一个广泛而深入的学习模型。https://www.tensorflow.org/versions/r1.3/tutorials/wide_and_deep
这是python源代码的链接:https ://github.com/tensorflow/tensorflow/blob/r1.3/tensorflow/examples/learn/wide_n_deep_tutorial.py
它的目标是训练一个模型,根据人口普查信息中的数据,该模型将预测某人的年收入是否超过或低于 50ka 美元。
按照指示,我正在运行此命令来执行:
python wide_n_deep_tutorial.py --model_type=wide_n_deep
我得到的结果如下:
$ python wide_n_deep.py --model_type=wide_n_deep
Training data is downloaded to /tmp/tmp_pwqo2h8
Test data is downloaded to /tmp/tmph6jcimik
2018-01-03 05:34:12.236038: I tensorflow/core/platform/cpu_feature_guard.cc:137] Your CPU supports instructions that this TensorFlow binary was not compiled to use: SSE4.1 SSE4.2 AVX AVX2 FMA
WARNING:tensorflow:enqueue_data was called with num_epochs and num_threads > 1. num_epochs is applied per thread, so this will produce more epochs than you probably intend. If you want to limit epochs, use one thread.
WARNING:tensorflow:enqueue_data was called with shuffle=False and num_threads > 1. This will create multiple threads, all reading the array/dataframe in order. If you want examples read in order, use one thread; if you want multiple threads, enable shuffling.
WARNING:tensorflow:Casting <dtype: 'float32'> labels to bool.
WARNING:tensorflow:Casting <dtype: 'float32'> labels to bool.
model directory = /tmp/tmp_ab6cfsf
accuracy: 0.808673
accuracy_baseline: 0.763774
auc: 0.841373
auc_precision_recall: 0.66043
average_loss: 0.418642
global_step: 2000
label/mean: 0.236226
loss: 41.8154
prediction/mean: 0.251593
在我在网上看到的各种文章中,它谈到了加载.ckpt
文件。当我查看我的模型目录时,我看到了这些文件:
$ ls /tmp/tmp_ab6cfsf
checkpoint eval events.out.tfevents.1514957651.ml-1 graph.pbtxt model.ckpt-1.data-00000-of-00001 model.ckpt-1.index model.ckpt-1.meta model.ckpt-2000.data-00000-of-00001 model.ckpt-2000.index model.ckpt-2000.meta
我猜我会使用的是model.ckpt-1.meta
,对吗?
但我也对如何使用和提供这个模型数据感到困惑。我在 Tensorflow 的网站上看过这篇文章:https ://www.tensorflow.org/versions/r1.3/programmers_guide/saved_model
上面写着“请注意,Estimators 会自动保存和恢复变量(在 model_dir 中)。” (不确定在这种情况下这意味着什么)
我如何生成人口普查数据格式的信息,除了工资,因为这是我们应该预测的?对我来说,如何使用两篇 Tensorflow 文章以便能够使用经过训练的模型进行预测并不明显。