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

structures don't have the same sequence type #22

Closed
ylfzr opened this issue Feb 18, 2018 · 12 comments
Closed

structures don't have the same sequence type #22

ylfzr opened this issue Feb 18, 2018 · 12 comments

Comments

@ylfzr
Copy link

ylfzr commented Feb 18, 2018

I ran python train.py --problem=mnist --save_path=./mnist.
And got the following error. I have no idea what is wrong with it, can anyboby help?

Traceback (most recent call last):
File "/Users/ylfzr/Documents/Projects/learning-to-learn-master/train.py", line 117, in
tf.app.run()
File "/Users/ylfzr/anaconda/lib/python2.7/site-packages/tensorflow/python/platform/app.py", line 48, in run
_sys.exit(main(_sys.argv[:1] + flags_passthrough))
File "/Users/ylfzr/Documents/Projects/learning-to-learn-master/train.py", line 70, in main
second_derivatives=FLAGS.second_derivatives)
File "/Users/ylfzr/Documents/Projects/learning-to-learn-master/meta.py", line 401, in meta_minimize
info = self.meta_loss(make_loss, len_unroll, **kwargs)
File "/Users/ylfzr/Documents/Projects/learning-to-learn-master/meta.py", line 360, in meta_loss
name="unroll")
File "/Users/ylfzr/anaconda/lib/python2.7/site-packages/tensorflow/python/ops/control_flow_ops.py", line 2775, in while_loop
result = context.BuildLoop(cond, body, loop_vars, shape_invariants)
File "/Users/ylfzr/anaconda/lib/python2.7/site-packages/tensorflow/python/ops/control_flow_ops.py", line 2604, in BuildLoop
pred, body, original_loop_vars, loop_vars, shape_invariants)
File "/Users/ylfzr/anaconda/lib/python2.7/site-packages/tensorflow/python/ops/control_flow_ops.py", line 2561, in _BuildLoop
nest.assert_same_structure(list(packed_vars_for_body), list(body_result))
File "/Users/ylfzr/anaconda/lib/python2.7/site-packages/tensorflow/python/util/nest.py", line 200, in assert_same_structure
_recursive_assert_same_structure(nest1, nest2, check_types)
File "/Users/ylfzr/anaconda/lib/python2.7/site-packages/tensorflow/python/util/nest.py", line 173, in _recursive_assert_same_structure
_recursive_assert_same_structure(n1, n2, check_types)
File "/Users/ylfzr/anaconda/lib/python2.7/site-packages/tensorflow/python/util/nest.py", line 173, in _recursive_assert_same_structure
_recursive_assert_same_structure(n1, n2, check_types)
File "/Users/ylfzr/anaconda/lib/python2.7/site-packages/tensorflow/python/util/nest.py", line 173, in _recursive_assert_same_structure
_recursive_assert_same_structure(n1, n2, check_types)
File "/Users/ylfzr/anaconda/lib/python2.7/site-packages/tensorflow/python/util/nest.py", line 173, in _recursive_assert_same_structure
_recursive_assert_same_structure(n1, n2, check_types)
File "/Users/ylfzr/anaconda/lib/python2.7/site-packages/tensorflow/python/util/nest.py", line 159, in _recursive_assert_same_structure
% (type_nest1, type_nest2))
TypeError: The two structures don't have the same sequence type. First structure has type <type 'tuple'>, while second structure has type <class 'sonnet.python.modules.gated_rnn.LSTMState'>.

Macos 10.12.6
tensorflow version used: 1.3.0

@louisfaury
Copy link

louisfaury commented Feb 19, 2018

I had the same problem today, on MacOs 10.12.6 and Tensorflow 1.4.0. Will be interested if you find how to fix it!

@chenaddsix
Copy link

I had the same problem today, on ubuntu 16.04 and tensorflow 1.4.0

@zjnqh
Copy link

zjnqh commented Apr 10, 2018

Encountering the same problem with Centos, kind of hoping for a solution.

@federicohyo
Copy link

I had the same problem. I solved it by using these versions of tensorflow and sonnet. dm-sonnet requires tensorflow 1.5 , see -> https://github.com/deepmind/sonnet .

pip uninstall tensorflow
pip uninstall dm-sonnet

pip install tensorflow==1.5.0
pip install dm-sonnet==1.7

I hope this helps,
Federico

@johnsears
Copy link

Would be helpful to check in a requirements.txt file.

@xiaozhouxiao
Copy link

same problem here - even though I have tensorflow 1.7. Does it have to be version 1.5? Has anyone tried/figured out a way around this? Thanks.

@jli238
Copy link

jli238 commented Jul 8, 2018

having the same problem even change to tf 1.5.0. Did anyone figure out any possible solutions to this problem yet? Thank you.

@mily33
Copy link

mily33 commented Aug 27, 2018

It is because the input and output of the LSTMcell don't have the same type in tf.while_loop. The problem can be solved by a slight change in meta.py.
line 305
state.append(_nested_variable( [net.initial_state_for_inputs(x[j], dtype=tf.float32) for j in subset], name="state", trainable=False))
to
state.append([net.initial_state_for_inputs(x[j], dtype=tf.float32) for j in subset])

line 368
variables = (nest.flatten(_nested_variable(state)) + x + constants)

line 377
update = (nest.flatten(_nested_assign(x, x_final)) + nest.flatten(_nested_assign(_nested_variable(state), s_final)))

Hope this help!

@hitvoice
Copy link

@mily33 's method works with tf1.4.1 on Mac and Ubuntu. Thanks!

@minhnhat93
Copy link

had similar problems, @mily33 solved the issues. would it be possible to have a PR to fix this on the main repo?

@hoangcuong2011
Copy link

It works like a charm! Thanks @mily33

@BigWZhu
Copy link

BigWZhu commented Nov 5, 2018

@mily33 Thanks a lot for solving the problem

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