Skip to content
This repository was archived by the owner on Mar 17, 2022. It is now read-only.
This repository was archived by the owner on Mar 17, 2022. It is now read-only.

image_data_format('channels_last') #11

@birdyalex

Description

@birdyalex

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions