it looks like all Keras->Pytorch examples provided with the package are for the case of "channels_first" image data format. I have been struggling to make it work for the case of "channels_last" format (default tensorflow behaviour). But I can't figure out how to handle one specific case.
The Keras->Pytorch conversion works fine if the number of out-channels before flattening equals 1 (the latest block of conv/pool just before FC-layers). But when one increases the number of channels to 2+ something starts to go wrong. I included a variable NUM_OUT_CHANNEL_BEFORE_FLATTENING in the begging of the notebook which controls how many channels should the network have.
It looks like the concatenation-by-channel pattern (Keras' Flatten() vs. Pytorch .view()) differs between these two frameworks. Do you have any idea what can cause such a behaviour and maybe a way how to handle it?
Hi Guido,
it looks like all Keras->Pytorch examples provided with the package are for the case of "channels_first" image data format. I have been struggling to make it work for the case of "channels_last" format (default tensorflow behaviour). But I can't figure out how to handle one specific case.
I modified a little bit the example notebook and put it here for clarity (https://github.com/birdyalex/nn-transfer/blob/master/example_channels_last.ipynb).
The Keras->Pytorch conversion works fine if the number of out-channels before flattening equals 1 (the latest block of conv/pool just before FC-layers). But when one increases the number of channels to 2+ something starts to go wrong. I included a variable NUM_OUT_CHANNEL_BEFORE_FLATTENING in the begging of the notebook which controls how many channels should the network have.
It looks like the concatenation-by-channel pattern (Keras' Flatten() vs. Pytorch .view()) differs between these two frameworks. Do you have any idea what can cause such a behaviour and maybe a way how to handle it?