# Keras model import problem: NHWC or NCHW

**URL:** <https://community.konduit.ai/t/keras-model-import-problem-nhwc-or-nchw/1714>\
**Category:** Uncategorized\
**Created:** [December 15, 2021, 9:37am UTC](https://community.konduit.ai/t/keras-model-import-problem-nhwc-or-nchw/1714 "2021-12-15T09:37:57Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![YourPeer](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.konduit.ai/yourpeer/32/686_2.png) [@YourPeer](https://community.konduit.ai/u/YourPeer)\
**Post date:** [December 15, 2021, 9:37am UTC](https://community.konduit.ai/t/keras-model-import-problem-nhwc-or-nchw/1714/1 "2021-12-15T09:37:57Z")

</div>

I have a problem, because the input data shape is NHWC, but the input data shape of imported Keras is NCHW, how can I solve this problem?

ComputationGraph vgg16Transfer = new TransferLearning.GraphBuilder(simplemodel)  
.fineTuneConfiguration(fineTuneConf)  
.setFeatureExtractor(“conv\_pw\_13\_bn”) //the specified layer and below are “frozen”  
.build();

Cannot do forward pass in Convolution layer (layer name = conv1, layer index = 2): input array channels does not match CNN layer configuration (data format = NHWC, data input channels = 224, [minibatch, height, width, channels]=[16, 4, 225, 224]; expected input channels = 3) (layer name: conv1, layer index: 2, layer type: ConvolutionLayer)

---

<div class="post-metadata">

**Author:** ![agibsonccc](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.konduit.ai/agibsonccc/32/697_2.png) [@agibsonccc](https://community.konduit.ai/u/agibsonccc)\
**Post date:** [December 15, 2021, 12:06pm UTC](https://community.konduit.ai/t/keras-model-import-problem-nhwc-or-nchw/1714/2 "2021-12-15T12:06:58Z")

</div>

@YourPeer could you clarify what it is you’re having issues with? Is this keras + transfer learning in dl4j? Separating the 2 questions would help. Ideally something end to end I could run would help. I’d also like to know your version you’re using.

---

<div class="post-metadata">

**Author:** ![YourPeer](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.konduit.ai/yourpeer/32/686_2.png) [@YourPeer](https://community.konduit.ai/u/YourPeer)\
**Post date:** [December 15, 2021, 2:55pm UTC](https://community.konduit.ai/t/keras-model-import-problem-nhwc-or-nchw/1714/3 "2021-12-15T14:55:35Z")

</div>

Thank you very much for your reply! I’m using DL4J-M1.1 version and I want to deploy transfer learning on my android phone. I’m currently importing Mobilenet(keras) model successfully, but when I feed data to the model, I have a channel mismatch problem, actually the model requires the input data format to be NHWC, however my data format is NCHW. The data is provided by DL4J–Flowers dataset.
