jiegzhan / multi-class-text-classification-cnn-rnn

Classify Kaggle San Francisco Crime Description into 39 classes. Build the model with CNN, RNN (GRU and LSTM) and Word Embeddings on Tensorflow.
https://www.kaggle.com/c/sf-crime/data
Apache License 2.0
599 stars 262 forks source link

Predicting fail using tensorflow 1.3.0 #29

Closed justlittle closed 7 years ago

justlittle commented 7 years ago

env: tensorflow (1.3.0)

using the demo data, execute the predict.py failed.

`(tf_env) [root@patsnap360svr multi-class-text-classification-cnn-rnn]# python predict.py ../trained_results_1506070488/ ../multi-class-text-classification-cnn-rnn-modified/data/small_samples.csv 2017-09-27 13:00:53.275348: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.1 instructions, but these are available on your machine and could speed up CPU computations. 2017-09-27 13:00:53.275444: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.2 instructions, but these are available on your machine and could speed up CPU computations. 2017-09-27 13:00:53.275473: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX instructions, but these are available on your machine and could speed up CPU computations. 2017-09-27 13:00:53.275492: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX2 instructions, but these are available on your machine and could speed up CPU computations. 2017-09-27 13:00:53.275510: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use FMA instructions, but these are available on your machine and could speed up CPU computations. WARNING:tensorflow:From predict.py:110: all_variables (from tensorflow.python.ops.variables) is deprecated and will be removed after 2017-03-02. Instructions for updating: Please use tf.global_variables instead. INFO:tensorflow:Restoring parameters from ../trained_results_1506070488/best_model.ckpt Traceback (most recent call last): File "/root/.virtualenvs/tf_env/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1327, in _do_call return fn(*args) File "/root/.virtualenvs/tf_env/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1306, in _run_fn status, run_metadata) File "/usr/local/lib/python3.6/contextlib.py", line 89, in exit next(self.gen) File "/root/.virtualenvs/tf_env/lib/python3.6/site-packages/tensorflow/python/framework/errors_impl.py", line 466, in raise_exception_on_not_ok_status pywrap_tensorflow.TF_GetCode(status)) tensorflow.python.framework.errors_impl.NotFoundError: Tensor name "conv-maxpool-3/b" not found in checkpoint files ../trained_results_1506070488/best_model.ckpt [[Node: save/RestoreV2_1 = RestoreV2[dtypes=[DT_FLOAT], _device="/job:localhost/replica:0/task:0/cpu:0"](_arg_save/Const_0_0, save/RestoreV2_1/tensor_names, save/RestoreV2_1/shape_and_slices)]]

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "predict.py", line 136, in predict_unseen_data() File "predict.py", line 112, in predict_unseen_data saver.restore(sess, checkpoint_file) File "/root/.virtualenvs/tf_env/lib/python3.6/site-packages/tensorflow/python/training/saver.py", line 1560, in restore {self.saver_def.filename_tensor_name: save_path}) File "/root/.virtualenvs/tf_env/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 895, in run run_metadata_ptr) File "/root/.virtualenvs/tf_env/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1124, in _run feed_dict_tensor, options, run_metadata) File "/root/.virtualenvs/tf_env/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1321, in _do_run options, run_metadata) File "/root/.virtualenvs/tf_env/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1340, in _do_call raise type(e)(node_def, op, message) tensorflow.python.framework.errors_impl.NotFoundError: Tensor name "conv-maxpool-3/b" not found in checkpoint files ../trained_results_1506070488/best_model.ckpt [[Node: save/RestoreV2_1 = RestoreV2[dtypes=[DT_FLOAT], _device="/job:localhost/replica:0/task:0/cpu:0"](_arg_save/Const_0_0, save/RestoreV2_1/tensor_names, save/RestoreV2_1/shape_and_slices)]]

Caused by op 'save/RestoreV2_1', defined at: File "predict.py", line 136, in predict_unseen_data() File "predict.py", line 110, in predict_unseen_data saver = tf.train.Saver(tf.all_variables()) File "/root/.virtualenvs/tf_env/lib/python3.6/site-packages/tensorflow/python/training/saver.py", line 1140, in init self.build() File "/root/.virtualenvs/tf_env/lib/python3.6/site-packages/tensorflow/python/training/saver.py", line 1172, in build filename=self._filename) File "/root/.virtualenvs/tf_env/lib/python3.6/site-packages/tensorflow/python/training/saver.py", line 688, in build restore_sequentially, reshape) File "/root/.virtualenvs/tf_env/lib/python3.6/site-packages/tensorflow/python/training/saver.py", line 407, in _AddRestoreOps tensors = self.restore_op(filename_tensor, saveable, preferred_shard) File "/root/.virtualenvs/tf_env/lib/python3.6/site-packages/tensorflow/python/training/saver.py", line 247, in restore_op [spec.tensor.dtype])[0]) File "/root/.virtualenvs/tf_env/lib/python3.6/site-packages/tensorflow/python/ops/gen_io_ops.py", line 663, in restore_v2 dtypes=dtypes, name=name) File "/root/.virtualenvs/tf_env/lib/python3.6/site-packages/tensorflow/python/framework/op_def_library.py", line 767, in apply_op op_def=op_def) File "/root/.virtualenvs/tf_env/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 2630, in create_op original_op=self._default_original_op, op_def=op_def) File "/root/.virtualenvs/tf_env/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 1204, in init self._traceback = self._graph._extract_stack() # pylint: disable=protected-access

NotFoundError (see above for traceback): Tensor name "conv-maxpool-3/b" not found in checkpoint files ../trained_results_1506070488/best_model.ckpt [[Node: save/RestoreV2_1 = RestoreV2[dtypes=[DT_FLOAT], _device="/job:localhost/replica:0/task:0/cpu:0"](_arg_save/Const_0_0, save/RestoreV2_1/tensor_names, save/RestoreV2_1/shape_and_slices)]]`

justlittle commented 7 years ago

already solved !!! :)

at tensorflow1.3.0 the best_model will be divide into 2 files, xx_model.index and xx_model.data-00000-of-00001 , when you need restore the model ,you can use tf.restore(sess,"xx_model")