# Why is Flux's data input format different?

**URL:** <https://discourse.julialang.org/t/why-is-fluxs-data-input-format-different/90490>\
**Category:** Machine Learning\
**Tags:** data, flux\
**Created:** [November 19, 2022, 10:16am UTC](https://discourse.julialang.org/t/why-is-fluxs-data-input-format-different/90490 "2022-11-19T10:16:58Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![v-i-s-h](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/v-i-s-h/32/46152_2.png) [@v-i-s-h](https://discourse.julialang.org/u/v-i-s-h)\
**Post date:** [November 19, 2022, 10:16am UTC](https://discourse.julialang.org/t/why-is-fluxs-data-input-format-different/90490/1 "2022-11-19T10:16:59Z")

</div>

Hi,

In Flux models (created using Chain), we give data array of the format `D x N` (`D` - data dimension, `N` - number of samples). This is is different from other ML libraries such as Tensorflow/PyTorch where we use `N x D` format.

This also results in the output (for a scalar prediction) being a `1 x N` matrix rather than a `N` dimensional vector (which is more intuitive, atleast to me).

I am curious to know what is the reason for this design?

Thanks,  
Vishnu

---

<div class="post-metadata">

**Author:** ![Tomas\_Pevny](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tomas_pevny/32/25466_2.png) [@Tomas\_Pevny](https://discourse.julialang.org/u/Tomas_Pevny)\
**Post date:** [November 19, 2022, 11:31am UTC](https://discourse.julialang.org/t/why-is-fluxs-data-input-format-different/90490/2 "2022-11-19T11:31:02Z")

</div>

Because PyTorch and Tensorflow are written in C/C++, which has row-major layout of matrices, where Julia has column major layout of matrices. Therefore for efficiency, things are reversed.
