Open mrtpk123 opened 3 years ago
You can convert between channels-first and channels-last with an n-dimensional matrix transpose. The Keras 'Permute' layer does exactly this:
https://www.tensorflow.org/api_docs/python/tf/keras/layers/Permute
This issue is stale because it has been open for 180 days with no activity. It will be closed if no further activity occurs. Thank you.
This issue is stale because it has been open for 180 days with no activity. It will be closed if no further activity occurs. Thank you.
Hello,
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 last data format (the default data format).
For some clarity, the current model summary looks like this:
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:
I raised an issue at TensorFlow and from a bit of searching I understood that this situation is not uncommon.
From this comment, I understood that we have to do a "network surgery" to accomplish this.
It would be great if you could provide a sample code on how to do this. Any help/pointers are really appreciated.
Thank you.