adeshpande3 / LSTM-Sentiment-Analysis

Sentiment Analysis with LSTMs in Tensorflow
MIT License
980 stars 431 forks source link

Not found error #22

Open xenonkfr opened 6 years ago

xenonkfr commented 6 years ago

hi, i am new in this area.while running the following code:

sess = tf.InteractiveSession()
saver = tf.train.Saver()
saver.restore(sess, tf.train.latest_checkpoint('models'))

i got this error: INFO:tensorflow:Restoring parameters from models\pretrained_lstm.ckpt-90000

NotFoundError Traceback (most recent call last) ~\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\client\session.py in _do_call(self, fn, args) 1322 try: -> 1323 return fn(args) 1324 except errors.OpError as e:

~\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\client\session.py in _run_fn(session, feed_dict, fetch_list, target_list, options, run_metadata) 1301 feed_dict, fetch_list, target_list, -> 1302 status, run_metadata) 1303

~\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\framework\errors_impl.py in exit(self, type_arg, value_arg, traceback_arg) 472 compat.as_text(c_api.TF_Message(self.status.status)), --> 473 c_api.TF_GetCode(self.status.status)) 474 # Delete the underlying status object from memory otherwise it stays alive

NotFoundError: Key rnn/basic_lstm_cell/kernel/Adam_1 not found in checkpoint [[Node: save/RestoreV2_14 = RestoreV2[dtypes=[DT_FLOAT], _device="/job:localhost/replica:0/task:0/device:CPU:0"](_arg_save/Const_0_0, save/RestoreV2_14/tensor_names, save/RestoreV2_14/shape_and_slices)]] [[Node: save/RestoreV2_7/_19 = _Recv[client_terminated=false, recv_device="/job:localhost/replica:0/task:0/device:GPU:0", send_device="/job:localhost/replica:0/task:0/device:CPU:0", send_device_incarnation=1, tensor_name="edge_52_save/RestoreV2_7", tensor_type=DT_FLOAT, _device="/job:localhost/replica:0/task:0/device:GPU:0"]()]]

During handling of the above exception, another exception occurred:

NotFoundError Traceback (most recent call last)

in () 1 sess = tf.InteractiveSession() 2 saver = tf.train.Saver() ----> 3 saver.restore(sess, tf.train.latest_checkpoint('models')) ~\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\training\saver.py in restore(self, sess, save_path) 1664 if context.in_graph_mode(): 1665 sess.run(self.saver_def.restore_op_name, -> 1666 {self.saver_def.filename_tensor_name: save_path}) 1667 else: 1668 self._build_eager(save_path, build_save=False, build_restore=True) ~\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\client\session.py in run(self, fetches, feed_dict, options, run_metadata) 887 try: 888 result = self._run(None, fetches, feed_dict, options_ptr, --> 889 run_metadata_ptr) 890 if run_metadata: 891 proto_data = tf_session.TF_GetBuffer(run_metadata_ptr) ~\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\client\session.py in _run(self, handle, fetches, feed_dict, options, run_metadata) 1118 if final_fetches or final_targets or (handle and feed_dict_tensor): 1119 results = self._do_run(handle, final_targets, final_fetches, -> 1120 feed_dict_tensor, options, run_metadata) 1121 else: 1122 results = [] ~\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\client\session.py in _do_run(self, handle, target_list, fetch_list, feed_dict, options, run_metadata) 1315 if handle is None: 1316 return self._do_call(_run_fn, self._session, feeds, fetches, targets, -> 1317 options, run_metadata) 1318 else: 1319 return self._do_call(_prun_fn, self._session, handle, feeds, fetches) ~\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\client\session.py in _do_call(self, fn, *args) 1334 except KeyError: 1335 pass -> 1336 raise type(e)(node_def, op, message) 1337 1338 def _extend_graph(self): NotFoundError: Key rnn/basic_lstm_cell/kernel/Adam_1 not found in checkpoint [[Node: save/RestoreV2_14 = RestoreV2[dtypes=[DT_FLOAT], _device="/job:localhost/replica:0/task:0/device:CPU:0"](_arg_save/Const_0_0, save/RestoreV2_14/tensor_names, save/RestoreV2_14/shape_and_slices)]] [[Node: save/RestoreV2_7/_19 = _Recv[client_terminated=false, recv_device="/job:localhost/replica:0/task:0/device:GPU:0", send_device="/job:localhost/replica:0/task:0/device:CPU:0", send_device_incarnation=1, tensor_name="edge_52_save/RestoreV2_7", tensor_type=DT_FLOAT, _device="/job:localhost/replica:0/task:0/device:GPU:0"]()]] Caused by op 'save/RestoreV2_14', defined at: File "C:\Users\TURNO\Anaconda3\envs\tensorflow\lib\runpy.py", line 193, in _run_module_as_main "__main__", mod_spec) File "C:\Users\TURNO\Anaconda3\envs\tensorflow\lib\runpy.py", line 85, in _run_code exec(code, run_globals) File "C:\Users\TURNO\Anaconda3\envs\tensorflow\lib\site-packages\ipykernel_launcher.py", line 16, in app.launch_new_instance() File "C:\Users\TURNO\Anaconda3\envs\tensorflow\lib\site-packages\traitlets\config\application.py", line 658, in launch_instance app.start() File "C:\Users\TURNO\Anaconda3\envs\tensorflow\lib\site-packages\ipykernel\kernelapp.py", line 478, in start self.io_loop.start() File "C:\Users\TURNO\Anaconda3\envs\tensorflow\lib\site-packages\zmq\eventloop\ioloop.py", line 177, in start super(ZMQIOLoop, self).start() File "C:\Users\TURNO\Anaconda3\envs\tensorflow\lib\site-packages\tornado\ioloop.py", line 888, in start handler_func(fd_obj, events) File "C:\Users\TURNO\Anaconda3\envs\tensorflow\lib\site-packages\tornado\stack_context.py", line 277, in null_wrapper return fn(*args, **kwargs) File "C:\Users\TURNO\Anaconda3\envs\tensorflow\lib\site-packages\zmq\eventloop\zmqstream.py", line 440, in _handle_events self._handle_recv() File "C:\Users\TURNO\Anaconda3\envs\tensorflow\lib\site-packages\zmq\eventloop\zmqstream.py", line 472, in _handle_recv self._run_callback(callback, msg) File "C:\Users\TURNO\Anaconda3\envs\tensorflow\lib\site-packages\zmq\eventloop\zmqstream.py", line 414, in _run_callback callback(*args, **kwargs) File "C:\Users\TURNO\Anaconda3\envs\tensorflow\lib\site-packages\tornado\stack_context.py", line 277, in null_wrapper return fn(*args, **kwargs) File "C:\Users\TURNO\Anaconda3\envs\tensorflow\lib\site-packages\ipykernel\kernelbase.py", line 283, in dispatcher return self.dispatch_shell(stream, msg) File "C:\Users\TURNO\Anaconda3\envs\tensorflow\lib\site-packages\ipykernel\kernelbase.py", line 233, in dispatch_shell handler(stream, idents, msg) File "C:\Users\TURNO\Anaconda3\envs\tensorflow\lib\site-packages\ipykernel\kernelbase.py", line 399, in execute_request user_expressions, allow_stdin) File "C:\Users\TURNO\Anaconda3\envs\tensorflow\lib\site-packages\ipykernel\ipkernel.py", line 208, in do_execute res = shell.run_cell(code, store_history=store_history, silent=silent) File "C:\Users\TURNO\Anaconda3\envs\tensorflow\lib\site-packages\ipykernel\zmqshell.py", line 537, in run_cell return super(ZMQInteractiveShell, self).run_cell(*args, **kwargs) File "C:\Users\TURNO\Anaconda3\envs\tensorflow\lib\site-packages\IPython\core\interactiveshell.py", line 2728, in run_cell interactivity=interactivity, compiler=compiler, result=result) File "C:\Users\TURNO\Anaconda3\envs\tensorflow\lib\site-packages\IPython\core\interactiveshell.py", line 2850, in run_ast_nodes if self.run_code(code, result): File "C:\Users\TURNO\Anaconda3\envs\tensorflow\lib\site-packages\IPython\core\interactiveshell.py", line 2910, in run_code exec(code_obj, self.user_global_ns, self.user_ns) File "", line 2, in saver = tf.train.Saver() File "C:\Users\TURNO\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\training\saver.py", line 1218, in __init__ self.build() File "C:\Users\TURNO\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\training\saver.py", line 1227, in build self._build(self._filename, build_save=True, build_restore=True) File "C:\Users\TURNO\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\training\saver.py", line 1263, in _build build_save=build_save, build_restore=build_restore) File "C:\Users\TURNO\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\training\saver.py", line 751, in _build_internal restore_sequentially, reshape) File "C:\Users\TURNO\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\training\saver.py", line 427, in _AddRestoreOps tensors = self.restore_op(filename_tensor, saveable, preferred_shard) File "C:\Users\TURNO\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\training\saver.py", line 267, in restore_op [spec.tensor.dtype])[0]) File "C:\Users\TURNO\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\ops\gen_io_ops.py", line 1020, in restore_v2 shape_and_slices=shape_and_slices, dtypes=dtypes, name=name) File "C:\Users\TURNO\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\framework\op_def_library.py", line 787, in _apply_op_helper op_def=op_def) File "C:\Users\TURNO\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\framework\ops.py", line 2956, in create_op op_def=op_def) File "C:\Users\TURNO\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\framework\ops.py", line 1470, in __init__ self._traceback = self._graph._extract_stack() # pylint: disable=protected-access NotFoundError (see above for traceback): Key rnn/basic_lstm_cell/kernel/Adam_1 not found in checkpoint [[Node: save/RestoreV2_14 = RestoreV2[dtypes=[DT_FLOAT], _device="/job:localhost/replica:0/task:0/device:CPU:0"](_arg_save/Const_0_0, save/RestoreV2_14/tensor_names, save/RestoreV2_14/shape_and_slices)]] [[Node: save/RestoreV2_7/_19 = _Recv[client_terminated=false, recv_device="/job:localhost/replica:0/task:0/device:GPU:0", send_device="/job:localhost/replica:0/task:0/device:CPU:0", send_device_incarnation=1, tensor_name="edge_52_save/RestoreV2_7", tensor_type=DT_FLOAT, _device="/job:localhost/replica:0/task:0/device:GPU:0"]()]]
adeshpande3 commented 6 years ago

https://github.com/adeshpande3/LSTM-Sentiment-Analysis/issues/20 Sorry, the code only works for Tensorflow version 1.1. Don't know of a fix right now, but will take a look soon

xenonkfr commented 6 years ago

thank you for your fast reply.i'll let you know if downgrading tensorflow fix that problem

rahulsinghpatel commented 6 years ago

@adeshpande3 ,I have TensorFlow 1.1. then also it is not working

joelvarma commented 5 years ago

@adeshpande3 ,I have TensorFlow 1.1. then also it is not working

It worked for me with tensorflow 1.1, did you try restarting the server?