continue trainning on pre-trained model
xingfan-git opened this issue · 1 comments
I want to train the pre-trained model with my own dataset. I found the 'train.py' and try to restore the pre-trained model as:
if net =='PNet':
saver = tf.train.import_meta_graph(r'./data/MTCNN_model/PNet_landmark/PNet-2.meta')
saver.restore(sess, tf.train.latest_checkpoint('./data/MTCNN_model/PNet_landmark/'))
I renamed pre-trained model as PNet-2, and use the checkpoint file at epoch 2. Then I got an error when I run the training code:
Instructions for updating:
To construct input pipelines, use the tf.data
module.
Traceback (most recent call last):
File "C:\Users\12132\AppData\Roaming\Python\Python37\site-packages\tensorflow\python\client\session.py", line 1356, in _do_call
return fn(*args)
File "C:\Users\12132\AppData\Roaming\Python\Python37\site-packages\tensorflow\python\client\session.py", line 1341, in _run_fn
options, feed_dict, fetch_list, target_list, run_metadata)
File "C:\Users\12132\AppData\Roaming\Python\Python37\site-packages\tensorflow\python\client\session.py", line 1429, in _call_tf_sessionrun
run_metadata)
tensorflow.python.framework.errors_impl.FailedPreconditionError: 2 root error(s) found.
(0) Failed precondition: Attempting to use uninitialized value Variable
[[{{node Variable/read}}]]
(1) Failed precondition: Attempting to use uninitialized value Variable
[[{{node Variable/read}}]]
[[_arg_bbox_target_0_1/_149]]
0 successful operations.
0 derived errors ignored.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File ".\train_models\train_PNet.py", line 31, in
train_PNet(base_dir, prefix, end_epoch, display, lr)
File ".\train_models\train_PNet.py", line 17, in train_PNet
train(net_factory,prefix, end_epoch, base_dir, display=display, base_lr=lr)
File "F:\HOME\MTCNN-Tensorflow\train_models\train.py", line 226, in train
,,summary = sess.run([train_op, lr_op ,summary_op], feed_dict={input_image: image_batch_array, label: label_batch_array, bbox_target: bbox_batch_array,landmark_target:landmark_batch_array})
File "C:\Users\12132\AppData\Roaming\Python\Python37\site-packages\tensorflow\python\client\session.py", line 950, in run
run_metadata_ptr)
File "C:\Users\12132\AppData\Roaming\Python\Python37\site-packages\tensorflow\python\client\session.py", line 1173, in _run
feed_dict_tensor, options, run_metadata)
File "C:\Users\12132\AppData\Roaming\Python\Python37\site-packages\tensorflow\python\client\session.py", line 1350, in _do_run
run_metadata)
File "C:\Users\12132\AppData\Roaming\Python\Python37\site-packages\tensorflow\python\client\session.py", line 1370, in _do_call
raise type(e)(node_def, op, message)
tensorflow.python.framework.errors_impl.FailedPreconditionError: 2 root error(s) found.
(0) Failed precondition: Attempting to use uninitialized value Variable
[[node Variable/read (defined at F:\HOME\MTCNN-Tensorflow\train_models\train.py:28) ]]
(1) Failed precondition: Attempting to use uninitialized value Variable
[[node Variable/read (defined at F:\HOME\MTCNN-Tensorflow\train_models\train.py:28) ]]
[[_arg_bbox_target_0_1/_149]]
0 successful operations.
0 derived errors ignored.
Original stack trace for 'Variable/read':
File ".\train_models\train_PNet.py", line 31, in
train_PNet(base_dir, prefix, end_epoch, display, lr)
File ".\train_models\train_PNet.py", line 17, in train_PNet
train(net_factory,prefix, end_epoch, base_dir, display=display, base_lr=lr)
File "F:\HOME\MTCNN-Tensorflow\train_models\train.py", line 166, in train
num)
File "F:\HOME\MTCNN-Tensorflow\train_models\train.py", line 28, in train_model
global_step = tf.Variable(0, trainable=False)
File "C:\Users\12132\AppData\Roaming\Python\Python37\site-packages\tensorflow\python\ops\variables.py", line 259, in call
return cls._variable_v1_call(*args, **kwargs)
File "C:\Users\12132\AppData\Roaming\Python\Python37\site-packages\tensorflow\python\ops\variables.py", line 220, in _variable_v1_call
shape=shape)
File "C:\Users\12132\AppData\Roaming\Python\Python37\site-packages\tensorflow\python\ops\variables.py", line 198, in
previous_getter = lambda **kwargs: default_variable_creator(None, **kwargs)
File "C:\Users\12132\AppData\Roaming\Python\Python37\site-packages\tensorflow\python\ops\variable_scope.py", line 2511, in default_variable_creator
shape=shape)
File "C:\Users\12132\AppData\Roaming\Python\Python37\site-packages\tensorflow\python\ops\variables.py", line 263, in call
return super(VariableMetaclass, cls).call(*args, **kwargs)
File "C:\Users\12132\AppData\Roaming\Python\Python37\site-packages\tensorflow\python\ops\variables.py", line 1568, in init
shape=shape)
File "C:\Users\12132\AppData\Roaming\Python\Python37\site-packages\tensorflow\python\ops\variables.py", line 1755, in _init_from_args
self._snapshot = array_ops.identity(self._variable, name="read")
File "C:\Users\12132\AppData\Roaming\Python\Python37\site-packages\tensorflow\python\util\dispatch.py", line 180, in wrapper
return target(*args, **kwargs)
File "C:\Users\12132\AppData\Roaming\Python\Python37\site-packages\tensorflow\python\ops\array_ops.py", line 86, in identity
ret = gen_array_ops.identity(input, name=name)
File "C:\Users\12132\AppData\Roaming\Python\Python37\site-packages\tensorflow\python\ops\gen_array_ops.py", line 4997, in identity
"Identity", input=input, name=name)
File "C:\Users\12132\AppData\Roaming\Python\Python37\site-packages\tensorflow\python\framework\op_def_library.py", line 788, in _apply_op_helper
op_def=op_def)
File "C:\Users\12132\AppData\Roaming\Python\Python37\site-packages\tensorflow\python\util\deprecation.py", line 507, in new_func
return func(*args, **kwargs)
File "C:\Users\12132\AppData\Roaming\Python\Python37\site-packages\tensorflow\python\framework\ops.py", line 3616, in create_op
op_def=op_def)
File "C:\Users\12132\AppData\Roaming\Python\Python37\site-packages\tensorflow\python\framework\ops.py", line 2005, in init
self._traceback = tf_stack.extract_stack()
Did you solve that problem, i got the same error as you