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

train_data = train_data.transpose((0, 3, 1, 2)) ValueError: axes don't match array #4

Open
monajalal opened this issue Jan 23, 2017 · 6 comments

Comments

@monajalal
Copy link

Hey, can you please help me fix this error?

mona@pascal:~/computer_vision/activity_recognition$ python kaggle_distracted_drivers_vgg16.py 
/usr/local/lib/python2.7/dist-packages/sklearn/cross_validation.py:44: DeprecationWarning: This module was deprecated in version 0.18 in favor of the model_selection module into which all the refactored classes and functions are moved. Also note that the interface of the new CV iterators are different from that of this module. This module will be removed in 0.20.
  "This module will be removed in 0.20.", DeprecationWarning)
Using TensorFlow backend.
I tensorflow/stream_executor/dso_loader.cc:111] successfully opened CUDA library libcublas.so.8.0 locally
I tensorflow/stream_executor/dso_loader.cc:111] successfully opened CUDA library libcudnn.so.5.0 locally
I tensorflow/stream_executor/dso_loader.cc:111] successfully opened CUDA library libcufft.so.8.0 locally
I tensorflow/stream_executor/dso_loader.cc:111] successfully opened CUDA library libcuda.so.1 locally
I tensorflow/stream_executor/dso_loader.cc:111] successfully opened CUDA library libcurand.so.8.0 locally
Read drivers data
Read train images
Load folder c0
Load folder c1
Load folder c2
Load folder c3
Load folder c4
Load folder c5
Load folder c6
Load folder c7
Load folder c8
Load folder c9
Read train data time: 0.04 seconds
Unique drivers: 0
[]
Convert to numpy...
Reshape...
Traceback (most recent call last):
  File "kaggle_distracted_drivers_vgg16.py", line 505, in <module>
    run_cross_validation_create_models(num_folds)
  File "kaggle_distracted_drivers_vgg16.py", line 379, in run_cross_validation_create_models
    train_data, train_target, train_id, driver_id, unique_drivers = read_and_normalize_train_data()
  File "kaggle_distracted_drivers_vgg16.py", line 201, in read_and_normalize_train_data
    train_data = train_data.transpose((0, 3, 1, 2))
ValueError: axes don't match array
@gourab5139014
Copy link

I'm running into a similar error with a different piece of code. How did you solve this?

@ZFTurbo
Copy link
Owner

ZFTurbo commented Apr 20, 2017

Check the train folder location. You read exactly 0 images. That's the issue.

@rahul0302
Copy link

Anyone from this issue, could you please explain why exactly do we use transpose((3,2,0,1))?
What does this give us?
Thank you!

@ZFTurbo
Copy link
Owner

ZFTurbo commented Jul 4, 2017

In Theano backend, channels should be on the second axis in array. But when we read with CV2 it's on the last place, So we just move it to needed location.

Let's say we have following tensor after reading images: (1000, 224, 224, 3) but we need it this way: (1000, 3, 224, 224) so we transpose it.

@AFIDclan
Copy link

Instead of:
train_data = train_data.transpose((0, 3, 1, 2))
use
train_data = train_data.transpose((2,0,1))

@smsubham
Copy link

I was getting a similar error. Resolved now.
There is something wrong with your dimension of the list you are passing and what it is expecting.
This link may help you in understanding how transpose() works.
https://stackoverflow.com/questions/32034237/how-does-numpys-transpose-method-permute-the-axes-of-an-array

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

6 participants