Skip to content

Commit

Permalink
scripts/training.py: Use keras.backend.image_data_format() to support…
Browse files Browse the repository at this point in the history
… newer keras version.

If you want to support newer Keras, then according to
[keras-team/keras#12649](keras-team/keras#12649)
the image_dim_ordering method has to be renamed to keras.backend.image_data_format()

This is the way to use the new Keras API:

setting:
K.set_image_dim_ordering('tf') --> K.set_image_data_format('channels_last')
K.set_image_dim_ordering('th') --> K.set_image_data_format('channels_first')

checking:
K.image_dim_ordering() == 'tf' --> K.image_data_format() == 'channels_last'
K.image_dim_ordering() == 'th' --> K.image_data_format() == 'channels_first'

Signed-off-by: Elvis Dowson <elvis.dowson@gmail.com>
  • Loading branch information
Elvis Dowson committed May 9, 2020
1 parent e3826c7 commit 861f8b7
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion scripts/training.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ def getResnetModel(d):
activation = d.act
advanced_act = d.aact
drop_prob = d.dropout
inputShape = (3, 32, 32) if K.image_dim_ordering() == "th" else (32, 32, 3)
inputShape = (3, 32, 32) if K.image_data_format() == "channels_first" else (32, 32, 3)
channelAxis = 1 if K.image_data_format() == 'channels_first' else -1
filsize = (3, 3)
convArgs = {
Expand Down

0 comments on commit 861f8b7

Please sign in to comment.