3

https://software.intel.com/en-us/forums/computer-vision/topic/785538

"The problem has been resolved. It's because the model I use uses channels_first as default for GPU training, while OPENVINO requires channels_last for TF models."

What do these mean?

How can I change them?

I cannot find any further references to this on the net.

Timbus Calin
  • 13,809
  • 5
  • 41
  • 59
Simon Kiely
  • 5,880
  • 28
  • 94
  • 180

3 Answers3

6

Channels first means that in a specific tensor (consider a photo), you would have (Number_Of_Channels, Height , Width).

Channels last means channels are on the last position in a tensor(n-dimensional array).

Examples:

    (3,360,720) --- Channels first

    (360,720,3) --- Channels last

where 3 comes from RGB (coloured image).

TensorFlow has by default channels last setting in the configuration.

The issue comes from the fact that some obsolete now frameworks(such as Theano) had a channels-first approach; porting was a problem particularly for newbies.

The solution to your problem would be to re-train your model in "Channels_Last" format.

Timbus Calin
  • 13,809
  • 5
  • 41
  • 59
  • Note Intel's OneDNN supports the *actual* channels-first layout `CHWN` in the `dnnl_format_tag_t` enum value [`dnnl_chwn`](https://oneapi-src.github.io/oneDNN/enum_dnnl_format_tag_t.html). Calling `NCHW` (which is *batch-first*) as channels-first causes confusion, versus explicit layout names like NCHW vs NHWC which are much less ambiguous. – Dwayne Robinson Aug 18 '23 at 02:09
1

You can convert TF model with NCHW layout to IR by using --disable_nhwc_to_nchw with Model Optimizer.

Dmitry
  • 46
  • 4
0

NCHW - channel first
NHWC - channel last

N:batch_size, C:no.of.channels, H:input_img_height, W:input_img_width

by default MKLDNN-plugin uses NCHW data layout.

mahinlma
  • 1,208
  • 3
  • 11
  • 24