Answers.Body: <p>It shouldn't matter for the accuracy of the network. But note that tensorflow/keras uses the (N, W, H, C) convention whereas pytorch uses the (N, C, W, H). So depending on what library you use, you need to make sure the inputs are shaped correctly before feeding it to the network.</p>
  <p>If you are trying to build a nerual network from scratch and training it with numpy, then ideally you would make the spatial dimensions last (..., W, H), to interface with functions such as np.convolve efficiently.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-08-27T20:15:57.753Z
Answers.LastActivityDate: 2022-08-27T20:15:57.753Z
Answers.UserDisplayName: PeaBrane
Body: <p>Image classification of RGB images in a Convolutional Neural Network is usually done by feeding the CNN first layer with a Numpy array with dimensions: pixel array by the number of channels. Example: [256 pixels] x [256 pixels] x [3 channels].</p>
  <p>What is the impact on performance if applying a different Numpy array in a different order: say [256 pixels] x [3 channels] x [256 pixels], assuming that the CNN first layer structure is changed?</p>
  <ol>
  <li>Does the CNN architecture of the sub-sequent layers need to be changed?</li>
  <li>Would the model prediction accuracy be impacted?</li>
  </ol>
  <p>My use case is a bit different where I have multiple features in a 5 dimensional Numpy Array [X pixels],[Y pixels],[N size],[M size],[L size] and I'm concerned that the order of how the features are entered into the CNN will impact the model training.</p>
  
Tags: <convolutional-neural-networks><python><image-processing>
Title: Does the order of a Numpy array matter for CNN classification?
UserDisplayName: cristiandatum
ThreadText: # Does the order of a Numpy array matter for CNN classification?
  
  (Asked by: username_0 on 2022-08-26)
  
  Image classification of RGB images in a Convolutional Neural Network is usually done by feeding the CNN first layer with a Numpy array with dimensions: pixel array by the number of channels. Example: [256 pixels] x [256 pixels] x [3 channels].
  
  What is the impact on performance if applying a different Numpy array in a different order: say [256 pixels] x [3 channels] x [256 pixels], assuming that the CNN first layer structure is changed?
  
  1. Does the CNN architecture of the sub-sequent layers need to be changed?
  2. Would the model prediction accuracy be impacted?
  
  My use case is a bit different where I have multiple features in a 5 dimensional Numpy Array [X pixels],[Y pixels],[N size],[M size],[L size] and I'm concerned that the order of how the features are entered into the CNN will impact the model training.
  
  **Tags:** convolutional-neural-networks, python, image-processing
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2022-08-27. Score: 4
  
  It shouldn't matter for the accuracy of the network. But note that tensorflow/keras uses the (N, W, H, C) convention whereas pytorch uses the (N, C, W, H). So depending on what library you use, you need to make sure the inputs are shaped correctly before feeding it to the network.
  
  If you are trying to build a nerual network from scratch and training it with numpy, then ideally you would make the spatial dimensions last (..., W, H), to interface with functions such as np.convolve efficiently.
  
  
  ---
  
  