I have a pre-trained Keras model (in h5 format) where all the layers operate on channel first data format. I want to convert this model to operate on the channel's last data format (the default data format). Does TensorFlow support this out of the box? Any help or pointers on how to do this is much appreciated.
For some clarity, the current model summary looks like this:
Model: "model"
__________________________________________________________________________________________________
Layer (type) Output Shape Param # Connected to
==================================================================================================
input0 (InputLayer) [(None, 3, 240, 320) 0
__________________________________________________________________________________________________
259_pad (ZeroPadding2D) (None, 3, 242, 322) 0 input0[0][0]
__________________________________________________________________________________________________
259 (Conv2D) (None, 16, 120, 160) 432 259_pad[0][0]
__________________________________________________________________________________________________
260 (BatchNormalization) (None, 16, 120, 160) 64 259[0][0]
__________________________________________________________________________________________________
261 (Activation) (None, 16, 120, 160) 0 260[0][0]
__________________________________________________________________________________________________
262_pad (ZeroPadding2D) (None, 16, 122, 162) 0 261[0][0]
__________________________________________________________________________________________________
262 (DepthwiseConv2D) (None, 16, 120, 160) 144 262_pad[0][0]
As you can see, it's in the channel first format. I want to convert each layer in the model to operate on channel last format. So the ideal model summary will be as follows:
Model: "model"
__________________________________________________________________________________________________
Layer (type) Output Shape Param # Connected to
==================================================================================================
input0 (InputLayer) [(None, 240, 320, 3) 0
__________________________________________________________________________________________________
259_pad (ZeroPadding2D) (None, 242, 322, 3) 0 input0[0][0]
__________________________________________________________________________________________________
259 (Conv2D) (None, 120, 160, 16) 432 259_pad[0][0]
__________________________________________________________________________________________________
260 (BatchNormalization) (None, 120, 160, 16) 64 259[0][0]
__________________________________________________________________________________________________
261 (Activation) (None, 120, 160, 16) 0 260[0][0]
__________________________________________________________________________________________________
262_pad (ZeroPadding2D) (None, 122, 162, 16) 0 261[0][0]
__________________________________________________________________________________________________
262 (DepthwiseConv2D) (None, 120, 160, 16) 144 262_pad[0][0]
Thanks.
Related: