Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error with TensorFlow 1.1.0 #30

Open
boyangumn opened this issue Jun 5, 2017 · 5 comments
Open

Error with TensorFlow 1.1.0 #30

boyangumn opened this issue Jun 5, 2017 · 5 comments

Comments

@boyangumn
Copy link

Hi, when I was running the copy task with the command you provided in the README, I got some variable scope related error. My environment is:
++++
Python: 2.7.12
TensorFlow: 1.1.0
++++
The error message is :
++++
[] Building a NTM model
Percent: [####################] 100.00% Finished.
[
] Building a loss model for seq_length 1
Traceback (most recent call last):
File "main.py", line 72, in
tf.app.run()
File "/net/mlfs01/export/users/byang/env-tensorflow/local/lib/python2.7/site-packages/tensorflow/python/platform/app.py", line 48, in run
_sys.exit(main(_sys.argv[:1] + flags_passthrough))
File "main.py", line 54, in main
cell, ntm = create_ntm(FLAGS, sess)
File "main.py", line 39, in create_ntm
test_max_length=config.test_max_length, scope=scope, **ntm_args)
File "/net/mlfs01/export/users/byang/working/NTM-tensorflow/ntm.py", line 83, in init
self.build_model(forward_only)
File "/net/mlfs01/export/users/byang/working/NTM-tensorflow/ntm.py", line 169, in build_model
global_step=self.global_step)
File "/net/mlfs01/export/users/byang/env-tensorflow/local/lib/python2.7/site-packages/tensorflow/python/training/optimizer.py", line 446, in apply_gradients
self._create_slots([_get_variable_for(v) for v in var_list])
File "/net/mlfs01/export/users/byang/env-tensorflow/local/lib/python2.7/site-packages/tensorflow/python/training/rmsprop.py", line 99, in _create_slots
self._get_or_make_slot(v, val_rms, "rms", self._name)
File "/net/mlfs01/export/users/byang/env-tensorflow/local/lib/python2.7/site-packages/tensorflow/python/training/optimizer.py", line 727, in _get_or_make_slot
named_slots[_var_key(var)] = slot_creator.create_slot(var, val, op_name)
File "/net/mlfs01/export/users/byang/env-tensorflow/local/lib/python2.7/site-packages/tensorflow/python/training/slot_creator.py", line 113, in create_slot
return _create_slot_var(primary, val, "", validate_shape, None, None)
File "/net/mlfs01/export/users/byang/env-tensorflow/local/lib/python2.7/site-packages/tensorflow/python/training/slot_creator.py", line 66, in _create_slot_var
validate_shape=validate_shape)
File "/net/mlfs01/export/users/byang/env-tensorflow/local/lib/python2.7/site-packages/tensorflow/python/ops/variable_scope.py", line 1049, in get_variable
use_resource=use_resource, custom_getter=custom_getter)
File "/net/mlfs01/export/users/byang/env-tensorflow/local/lib/python2.7/site-packages/tensorflow/python/ops/variable_scope.py", line 948, in get_variable
use_resource=use_resource, custom_getter=custom_getter)
File "/net/mlfs01/export/users/byang/env-tensorflow/local/lib/python2.7/site-packages/tensorflow/python/ops/variable_scope.py", line 356, in get_variable
validate_shape=validate_shape, use_resource=use_resource)
File "/net/mlfs01/export/users/byang/env-tensorflow/local/lib/python2.7/site-packages/tensorflow/python/ops/variable_scope.py", line 341, in _true_getter
use_resource=use_resource)
File "/net/mlfs01/export/users/byang/env-tensorflow/local/lib/python2.7/site-packages/tensorflow/python/ops/variable_scope.py", line 671, in _get_single_variable
"VarScope?" % name)
ValueError: Variable NTM-copy/NTM-copy_1/init_cell/Variable/RMSProp/ does not exist, or was not created with tf.get_variable(). Did you mean to set reuse=None in VarScope?
(env-tensorflow) byang@snake10:/net/mlfs01/export/users/byang/working/NTM-tensorflow$ python
Python 2.7.12 (default, Nov 19 2016, 06:48:10)
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.

import tensorflow as tf
tf.version
'1.1.0'

++++++
I failed to resolve this issue, can you take a look and see what happened? Thanks.

@louiekang
Copy link

pay attention to the 'reuse' in ntm.py
reuse = seq_length != 1
with tf.variable_scope(tf.get_variable_scope(), reuse=reuse):
self.optims[seq_length] = opt.apply_gradients(
zip(grads, self.params),
global_step=self.global_step)

@boyangumn
Copy link
Author

Thank you @louiekang . I did notice that those lines might be the source of problem. But I do not know how to fix it. Can you please take a look and see what modifications are needed?

@laxris
Copy link

laxris commented Jul 4, 2017

@boyangumn, @louiekang is there a solution? Setting reuse to None does not help here.

@geandwor
Copy link

You may change the reuse to tf.AUTO_REUSE, but after the
[] Build a NTM model finished
[
] Initialize all variables
[] Initialization finished
[
] Reading checkpoints...
I met the problem when the program executes
ntm/NTM-tensorflow/tasks/copy.py", line 73, in train
ntm.load(config.checkpoint_dir, config.task, strict=config.continue_train is True)

NotFoundError: Key NTM-copy/NTM-copy/controller/forget_gate_0/Bias/RMSProp not found in checkpoint

@MortezaKarimian
Copy link

very good, change the reuse to tf.AUTO_REUSE work for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants