What is the correct way to change image channel ordering between channels first and channels last?
I can not for the life of me figure out how to switch the image ordering. images are read in (x,x,3) format, theano requires it to be in (3,x,x) format. I tried changing the order with numpy.array([img[:,:,i] for i in range(3)]) which i guess gets the job done, but it is both ugly and i can't figure out how to reverse it to get the original image back.
To reorder data You can use numpy.swapaxes for that. But, if you're using keras, theano doesn't require anything. Keras can be configured with channels first or channels last, besides allowing you to define it in every individual layer, so you don't have to change your data. To configure keras Find the keras.json file and change it. The file is usually in C:\Users\yourusername\.keras (the folder where keras was installed) Change "image_data_format": "channels_last" to "channels_first" or vice-versa, as you wish. Defining channel order in layers. The Keras documentation has all information about parameters for layers, including the data_format parameter.
Text file not being imported with module
Web.py - prevent caching of code/output
Reference counting while adding element to list
Python: Trouble with dill installation
python open file error
Dealing with Sprites and Collisions Using Pygame
Pip-installed module does not import
Does a trailing comma after an n-tuple in Python change its value?
Program that either waits for user input or runs at defined intervals?
pexpect for passwordless access does not work
Kivy Widget does not accepts properties and commands
Efficient combinations of combinations
what metric should I monitor for a spider in scrapy
Why is Aptana/Pydev showing “undefined variable” errors for “print” and “__name__” in my helloworld python code?
Python Tkinter: Delete label not working
How to call a function after adding values to an Option Menu?