KAGGLE_DISTRACTED_DRIVER
KAGGLE_DISTRACTED_DRIVER copied to clipboard
train_data = train_data.transpose((0, 3, 1, 2)) ValueError: axes don't match array
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
I'm running into a similar error with a different piece of code. How did you solve this?
Check the train folder location. You read exactly 0 images. That's the issue.
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!
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.
Instead of:
train_data = train_data.transpose((0, 3, 1, 2))
use
train_data = train_data.transpose((2,0,1))
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