python


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.

Related Links

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?

Categories

HOME
plsql
angular-cli
windows-7
label
specflow
iso
abcpdf
squarespace
react-leaflet
jquery-terminal
bootstrap-popover
google-people
propel2
jive
raphael
google-maps-android-api-2
prediction
scalaz7
ghost-inspector
explode
restfb
metadata-extractor
frp
dhtmlx-scheduler
expand
threshold
openshift-enterprise
axis-labels
declare
initializer
duktape
fax
wsadmin
sendgrid-templates
nashorn
stereo-3d
distributed-transactions
stress-testing
resuming-training
rdw
chunked-encoding
spring-data-hadoop
etherpad
quintus
iphone-developer-program
python-hypothesis
qos
bettercms
spyne
project-template
pdflib
tuxedo
dts
bacnet
dojox.charting
emokit
amazon-kcl
axes
servlet-3.0
android-snackbar
wif
type-mismatch
divide-by-zero
scrollspy
virus
sqoop2
chaining
moai
node-inspector
code-testing
delphi-xe3
late-static-binding
factors
cilk-plus
goinstant
leptonica
vertical-scrolling
dynamic-data
usn
tfs-power-tools
icefaces-3
continuous-testing
parameterization
file-exists
maven-ant-tasks
flash-cs5.5
nssavepanel
path-manipulation
for-xml-path
chatroom
pantheios
hardware-acceleration
delegatecommand
scatterview
associativity

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App