VansFannel
VansFannel

Reputation: 46041

Migrate Convolutional2D dim_ordering parameter to Conv2D in tf.keras

I'm newbie with Tensorflow and Keras, and I'm migrating the following code:

Convolution2D(64, 5, 5, activation='relu', border_mode='same', dim_ordering='tf', name='conv1_1')(inputs)

The interpreter suggest me this code:

Conv2D(64, (5, 5), activation="relu", name="conv1_1", padding="same", data_format="channels_last")

My question is:

Is dim_ordering='tf' the same as data_format="channels_last"?

Upvotes: 0

Views: 1128

Answers (2)

Ziku
Ziku

Reputation: 461

For the new api, you'll have to convert dim_ordering to data_format and the corresponding values are tf -> channels_last or th -> channels_first. So

# for dim_ordering = 'tf'
data_format =  'channels_last'


# for dim_ordering = 'th'
data_format =  'channels_first'

Upvotes: 0

Daniel Möller
Daniel Möller

Reputation: 86650

Yes, dim_ordering='tf' is equal to data_format="channels_last", which is also the default, so most of the times you might simply ignore this parameter.

This site seems to store old Keras documentation pages where you can confirm this: http://faroit.com/keras-docs/1.0.8/layers/convolutional/#convolution2d

Upvotes: 3

Related Questions