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

Convolution expects input with rank 4, got 5 #39

Closed
hungryquiter opened this issue Aug 7, 2018 · 9 comments
Closed

Convolution expects input with rank 4, got 5 #39

hungryquiter opened this issue Aug 7, 2018 · 9 comments

Comments

@hungryquiter
Copy link

Traceback (most recent call last):
File "./code/1-development/train_softmax.py", line 602, in
tf.app.run()
File "/opt/tensorflow/python2.7/local/lib/python2.7/site-packages/tensorflow/python/platform/app.py", line 125, in run
_sys.exit(main(argv))
File "./code/1-development/train_softmax.py", line 414, in main
logits, end_points_speech = model_speech_fn(batch_speech[i * step: (i + 1) * step])
File "/opt/speaker-recognition/code/1-development/nets/nets_factory.py", line 59, in network_fn
return func(images, num_classes, is_training=is_training)
File "/opt/speaker-recognition/code/1-development/nets/cnn_speech.py", line 118, in speech_cnn
net = slim.conv2d(inputs, 16, [3, 1, 5], stride=[1, 1, 1], scope='conv11')
File "/opt/tensorflow/python2.7/local/lib/python2.7/site-packages/tensorflow/contrib/framework/python/ops/arg_scope.py", line 183, in func_with_args
return func(*args, **current_args)
File "/opt/tensorflow/python2.7/local/lib/python2.7/site-packages/tensorflow/contrib/layers/python/layers/layers.py", line 1154, in convolution2d
conv_dims=2)
File "/opt/tensorflow/python2.7/local/lib/python2.7/site-packages/tensorflow/contrib/framework/python/ops/arg_scope.py", line 183, in func_with_args
return func(*args, **current_args)
File "/opt/tensorflow/python2.7/local/lib/python2.7/site-packages/tensorflow/contrib/layers/python/layers/layers.py", line 1025, in convolution
(conv_dims + 2, input_rank))
ValueError: Convolution expects input with rank 4, got 5

@hungryquiter
Copy link
Author

which version of tensorflow

@imranparuk
Copy link

related to issue 38 maybe?

@astorfi
Copy link
Owner

astorfi commented Aug 22, 2018

@imranparuk Yes. Thanks for pointing it out.

@astorfi
Copy link
Owner

astorfi commented Aug 22, 2018

It's a versioning problem.

@dzfowen
Copy link

dzfowen commented Sep 1, 2018

@astorfi hi another question: problem about

Squeeze spatially to eliminate extra dimensions.(embedding layer)

        if spatial_squeeze:
            logits = tf.squeeze(logits, [1, 2, 3], name='fc/squeezed')

a error happened , could I USE logits = tf.squeeze(logits, name='fc/squeezed') instead?

@imranparuk
Copy link

Hi @dzfowen , the code works out the box, you do not need to change anything. Your issue is that you have the incorrect version of numpy+tensorflow. This will be eventually sorted out i'm sure but for now what you need to do is use a virtual environment, uninstall numpy, install tensorflow version 1 which ships with its own numpy. This should fix your issues.

@dzfowen
Copy link

dzfowen commented Sep 3, 2018

@imranparuk Hi! Thanks for your reply. I mean if I delete [1,2,3], the squeeze() will have the same function as the author's intention, is it right? The new api of squeeze() asked provided specific dimension must contain a 1 at least.

@imranparuk
Copy link

      spatial_squeeze: whether or not should squeeze the spatial dimensions of the
        outputs. Useful to remove unnecessary dimensions for classification.

@dzfowen, no problem. I think it is possible to get the implementation working without the spatial squeeze, it seems to just be there to speed up training (The author should comment its use in more depth). However if python is complaining about dimensions with regard to the squeeze or any other portions of the model it is a good indication that your source of error is due to the mismatch in tensorflow and numpy versions.

@astorfi astorfi closed this as completed Sep 21, 2018
@luoqingshan
Copy link

Convolution expects input with rank 4, got 2

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