Trying to implement my first pLSTM powered RNN and ran in to this problem. Can't figure it out.
Code
#create pLSTM network
pLSTMmodel = Sequential()
pLSTMmodel.add(PLSTM(10, input_shape=(1, 10)))
#model.add(Dropout(.5, input_shape=(60,)))
pLSTMmodel.add(Dense(1))
pLSTMmodel.compile(loss='mean_squared_error', optimizer='adam', metrics=['mae', 'acc'])
pLSTMmodel.fit(trainCurrent, trainFutureAQI, epochs=5, batch_size=10, verbose=2)
Full trace back
FailedPreconditionError Traceback (most recent call last)
C:\Users\Christopher\Anaconda2\envs\tensorflow\lib\site-packages\tensorflow\python\client\session.py in _do_call(self, fn, *args)
1021 try:
-> 1022 return fn(*args)
1023 except errors.OpError as e:
C:\Users\Christopher\Anaconda2\envs\tensorflow\lib\site-packages\tensorflow\python\client\session.py in _run_fn(session, feed_dict, fetch_list, target_list, options, run_metadata)
1003 feed_dict, fetch_list, target_list,
-> 1004 status, run_metadata)
1005
C:\Users\Christopher\Anaconda2\envs\tensorflow\lib\contextlib.py in exit(self, type, value, traceback)
65 try:
---> 66 next(self.gen)
67 except StopIteration:
C:\Users\Christopher\Anaconda2\envs\tensorflow\lib\site-packages\tensorflow\python\framework\errors_impl.py in raise_exception_on_not_ok_status()
465 compat.as_text(pywrap_tensorflow.TF_Message(status)),
--> 466 pywrap_tensorflow.TF_GetCode(status))
467 finally:
FailedPreconditionError: Attempting to use uninitialized value phased_lstm_2/Variable
[[Node: phased_lstm_2/Variable/read = IdentityT=DT_FLOAT, _class=["loc:@phased_lstm_2/Variable"], _device="/job:localhost/replica:0/task:0/cpu:0"]]
During handling of the above exception, another exception occurred:
FailedPreconditionError Traceback (most recent call last)
in ()
5 pLSTMmodel.add(Dense(1))
6 pLSTMmodel.compile(loss='mean_squared_error', optimizer='adam', metrics=['mae', 'acc'])
----> 7 pLSTMmodel.fit(trainCurrent, trainFutureAQI, epochs=5, batch_size=10, verbose=2)
C:\Users\Christopher\Anaconda2\envs\tensorflow\lib\site-packages\keras\models.py in fit(self, x, y, batch_size, epochs, verbose, callbacks, validation_split, validation_data, shuffle, class_weight, sample_weight, initial_epoch, **kwargs)
843 class_weight=class_weight,
844 sample_weight=sample_weight,
--> 845 initial_epoch=initial_epoch)
846
847 def evaluate(self, x, y, batch_size=32, verbose=1,
C:\Users\Christopher\Anaconda2\envs\tensorflow\lib\site-packages\keras\engine\training.py in fit(self, x, y, batch_size, epochs, verbose, callbacks, validation_split, validation_data, shuffle, class_weight, sample_weight, initial_epoch, **kwargs)
1483 val_f=val_f, val_ins=val_ins, shuffle=shuffle,
1484 callback_metrics=callback_metrics,
-> 1485 initial_epoch=initial_epoch)
1486
1487 def evaluate(self, x, y, batch_size=32, verbose=1, sample_weight=None):
C:\Users\Christopher\Anaconda2\envs\tensorflow\lib\site-packages\keras\engine\training.py in _fit_loop(self, f, ins, out_labels, batch_size, epochs, verbose, callbacks, val_f, val_ins, shuffle, callback_metrics, initial_epoch)
1138 batch_logs['size'] = len(batch_ids)
1139 callbacks.on_batch_begin(batch_index, batch_logs)
-> 1140 outs = f(ins_batch)
1141 if not isinstance(outs, list):
1142 outs = [outs]
C:\Users\Christopher\Anaconda2\envs\tensorflow\lib\site-packages\keras\backend\tensorflow_backend.py in call(self, inputs)
2071 value = (indices, sparse_coo.data, sparse_coo.shape)
2072 feed_dict[tensor] = value
-> 2073 session = get_session()
2074 updated = session.run(self.outputs + [self.updates_op],
2075 feed_dict=feed_dict)
C:\Users\Christopher\Anaconda2\envs\tensorflow\lib\site-packages\keras\backend\tensorflow_backend.py in get_session()
151 session = _SESSION
152 if not _MANUAL_VAR_INIT:
--> 153 _initialize_variables()
154 return session
155
C:\Users\Christopher\Anaconda2\envs\tensorflow\lib\site-packages\keras\backend\tensorflow_backend.py in _initialize_variables()
304 if uninitialized_variables:
305 sess = get_session()
--> 306 sess.run(tf.variables_initializer(uninitialized_variables))
307
308
C:\Users\Christopher\Anaconda2\envs\tensorflow\lib\site-packages\tensorflow\python\client\session.py in run(self, fetches, feed_dict, options, run_metadata)
765 try:
766 result = self._run(None, fetches, feed_dict, options_ptr,
--> 767 run_metadata_ptr)
768 if run_metadata:
769 proto_data = tf_session.TF_GetBuffer(run_metadata_ptr)
C:\Users\Christopher\Anaconda2\envs\tensorflow\lib\site-packages\tensorflow\python\client\session.py in _run(self, handle, fetches, feed_dict, options, run_metadata)
963 if final_fetches or final_targets:
964 results = self._do_run(handle, final_targets, final_fetches,
--> 965 feed_dict_string, options, run_metadata)
966 else:
967 results = []
C:\Users\Christopher\Anaconda2\envs\tensorflow\lib\site-packages\tensorflow\python\client\session.py in _do_run(self, handle, target_list, fetch_list, feed_dict, options, run_metadata)
1013 if handle is None:
1014 return self._do_call(_run_fn, self._session, feed_dict, fetch_list,
-> 1015 target_list, options, run_metadata)
1016 else:
1017 return self._do_call(_prun_fn, self._session, handle, feed_dict,
C:\Users\Christopher\Anaconda2\envs\tensorflow\lib\site-packages\tensorflow\python\client\session.py in _do_call(self, fn, *args)
1033 except KeyError:
1034 pass
-> 1035 raise type(e)(node_def, op, message)
1036
1037 def _extend_graph(self):
FailedPreconditionError: Attempting to use uninitialized value phased_lstm_2/Variable
[[Node: phased_lstm_2/Variable/read = IdentityT=DT_FLOAT, _class=["loc:@phased_lstm_2/Variable"], _device="/job:localhost/replica:0/task:0/cpu:0"]]
Caused by op 'phased_lstm_2/Variable/read', defined at:
File "C:\Users\Christopher\Anaconda2\envs\tensorflow\lib\runpy.py", line 193, in _run_module_as_main
"main", mod_spec)
File "C:\Users\Christopher\Anaconda2\envs\tensorflow\lib\runpy.py", line 85, in run_code
exec(code, run_globals)
File "C:\Users\Christopher\Anaconda2\envs\tensorflow\lib\site-packages\ipykernel_main.py", line 3, in
app.launch_new_instance()
File "C:\Users\Christopher\Anaconda2\envs\tensorflow\lib\site-packages\traitlets\config\application.py", line 658, in launch_instance
app.start()
File "C:\Users\Christopher\Anaconda2\envs\tensorflow\lib\site-packages\ipykernel\kernelapp.py", line 474, in start
ioloop.IOLoop.instance().start()
File "C:\Users\Christopher\Anaconda2\envs\tensorflow\lib\site-packages\zmq\eventloop\ioloop.py", line 177, in start
super(ZMQIOLoop, self).start()
File "C:\Users\Christopher\Anaconda2\envs\tensorflow\lib\site-packages\tornado\ioloop.py", line 887, in start
handler_func(fd_obj, events)
File "C:\Users\Christopher\Anaconda2\envs\tensorflow\lib\site-packages\tornado\stack_context.py", line 275, in null_wrapper
return fn(*args, **kwargs)
File "C:\Users\Christopher\Anaconda2\envs\tensorflow\lib\site-packages\zmq\eventloop\zmqstream.py", line 440, in _handle_events
self._handle_recv()
File "C:\Users\Christopher\Anaconda2\envs\tensorflow\lib\site-packages\zmq\eventloop\zmqstream.py", line 472, in _handle_recv
self._run_callback(callback, msg)
File "C:\Users\Christopher\Anaconda2\envs\tensorflow\lib\site-packages\zmq\eventloop\zmqstream.py", line 414, in _run_callback
callback(*args, **kwargs)
File "C:\Users\Christopher\Anaconda2\envs\tensorflow\lib\site-packages\tornado\stack_context.py", line 275, in null_wrapper
return fn(*args, **kwargs)
File "C:\Users\Christopher\Anaconda2\envs\tensorflow\lib\site-packages\ipykernel\kernelbase.py", line 276, in dispatcher
return self.dispatch_shell(stream, msg)
File "C:\Users\Christopher\Anaconda2\envs\tensorflow\lib\site-packages\ipykernel\kernelbase.py", line 228, in dispatch_shell
handler(stream, idents, msg)
File "C:\Users\Christopher\Anaconda2\envs\tensorflow\lib\site-packages\ipykernel\kernelbase.py", line 390, in execute_request
user_expressions, allow_stdin)
File "C:\Users\Christopher\Anaconda2\envs\tensorflow\lib\site-packages\ipykernel\ipkernel.py", line 196, in do_execute
res = shell.run_cell(code, store_history=store_history, silent=silent)
File "C:\Users\Christopher\Anaconda2\envs\tensorflow\lib\site-packages\ipykernel\zmqshell.py", line 501, in run_cell
return super(ZMQInteractiveShell, self).run_cell(*args, **kwargs)
File "C:\Users\Christopher\Anaconda2\envs\tensorflow\lib\site-packages\IPython\core\interactiveshell.py", line 2717, in run_cell
interactivity=interactivity, compiler=compiler, result=result)
File "C:\Users\Christopher\Anaconda2\envs\tensorflow\lib\site-packages\IPython\core\interactiveshell.py", line 2821, in run_ast_nodes
if self.run_code(code, result):
File "C:\Users\Christopher\Anaconda2\envs\tensorflow\lib\site-packages\IPython\core\interactiveshell.py", line 2881, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "", line 3, in
pLSTMmodel.add(PLSTM(10, input_shape=(1, 10)))
File "C:\Users\Christopher\Anaconda2\envs\tensorflow\lib\site-packages\keras\models.py", line 422, in add
layer(x)
File "C:\Users\Christopher\Anaconda2\envs\tensorflow\lib\site-packages\keras\layers\recurrent.py", line 252, in call
return super(Recurrent, self).call(inputs, **kwargs)
File "C:\Users\Christopher\Anaconda2\envs\tensorflow\lib\site-packages\keras\engine\topology.py", line 519, in call
self.build(input_shapes[0])
File "C:\Users\Christopher\Anaconda2\envs\tensorflow\lib\site-packages\phased_lstm_keras-1.0.1-py3.5.egg\phased_lstm_keras\PhasedLSTM.py", line 245, in build
constraint=self.timegate_constraint)
File "C:\Users\Christopher\Anaconda2\envs\tensorflow\lib\site-packages\keras\engine\topology.py", line 355, in add_weight
weight = K.variable(initializer(shape), dtype=K.floatx(), name=name)
File "C:\Users\Christopher\Anaconda2\envs\tensorflow\lib\site-packages\phased_lstm_keras-1.0.1-py3.5.egg\phased_lstm_keras\PhasedLSTM.py", line 66, in _timegate_initializer
dtype=dtype)
File "C:\Users\Christopher\Anaconda2\envs\tensorflow\lib\site-packages\keras\backend\tensorflow_backend.py", line 286, in variable
v = tf.Variable(value, dtype=_convert_string_dtype(dtype), name=name)
File "C:\Users\Christopher\Anaconda2\envs\tensorflow\lib\site-packages\tensorflow\python\ops\variables.py", line 197, in init
expected_shape=expected_shape)
File "C:\Users\Christopher\Anaconda2\envs\tensorflow\lib\site-packages\tensorflow\python\ops\variables.py", line 315, in _init_from_args
self._snapshot = array_ops.identity(self._variable, name="read")
File "C:\Users\Christopher\Anaconda2\envs\tensorflow\lib\site-packages\tensorflow\python\ops\gen_array_ops.py", line 1490, in identity
result = _op_def_lib.apply_op("Identity", input=input, name=name)
File "C:\Users\Christopher\Anaconda2\envs\tensorflow\lib\site-packages\tensorflow\python\framework\op_def_library.py", line 763, in apply_op
op_def=op_def)
File "C:\Users\Christopher\Anaconda2\envs\tensorflow\lib\site-packages\tensorflow\python\framework\ops.py", line 2327, in create_op
original_op=self._default_original_op, op_def=op_def)
File "C:\Users\Christopher\Anaconda2\envs\tensorflow\lib\site-packages\tensorflow\python\framework\ops.py", line 1226, in init
self._traceback = _extract_stack()
FailedPreconditionError (see above for traceback): Attempting to use uninitialized value phased_lstm_2/Variable
[[Node: phased_lstm_2/Variable/read = IdentityT=DT_FLOAT, _class=["loc:@phased_lstm_2/Variable"], _device="/job:localhost/replica:0/task:0/cpu:0"]]