Answers.Body: <p>As stated in your example, the three features are: an image, a price, a rating. Now, you want to build a model that uses all of these features and the simplest way to do is to feed them directly into the neural network, but it's inefficient and fundamentally flawed, due to the following reasons:</p>
  <ul>
  <li><p>In the first dense layer, the neural network will try to combine raw pixel values linearly with price and rating, which will produce features that are meaningless for inference.</p>
  </li>
  <li><p>It could perform well just by optimizing the cost function, but the model performance will be nowhere as good as it could perform with a good architecture.</p>
  </li>
  </ul>
  <p>So, the neural network doesn't care if the data is a raw pixel value, price, or rating: it would just optimize it to produce the desired output. That is why it is necessary to design a suitable architecture for the given problem.</p>
  <p>Possible architecture for your given example :</p>
  <ol>
  <li><p>Separate your raw features, i.e. pixel value, and high-level data, i.e. price and rating</p>
  </li>
  <li><p>Stack 2-3 dense layers for raw features (to find complex patterns in images)</p>
  </li>
  <li><p>Stack 1-2 dense layers for high-level features</p>
  </li>
  <li><p>Combine them together in a final dense layer</p>
  </li>
  </ol>
  <p>If you want to de-emphasize the importance of the image, just connect the first dense layer 16,384 to another layer having fewer connections, say 1024, and have more connections from the high-level data, say 2048.</p>
  <p>So, again, here's the possible architecture</p>
  <ol>
  <li>Raw features -&gt; dense layer (16384) -&gt; dense layer (1024)</li>
  <li>High-level features -&gt; dense layer (2048)</li>
  <li>Combine 1 and 2 with another dense layer</li>
  </ol>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-02-21T08:48:47.957Z
Answers.LastActivityDate: 2020-11-21T20:30:39.293Z
Answers.LastEditDate: 2020-11-21T20:30:39.293Z
Answers.UserDisplayName: ssh
Answers.Body: <p>The answer by ssh is correct. Your results could be further improved i) by extracting image features by a convolutional (instead of fully connected) architecture, and ii) by exploiting transfer learning. </p>
  
  <p>To exploit transfer learning you i) pick some widely used model, eg. ResNet-18, ii) initialize it with ImageNet pretrained parameters, iii) replace its fully connected layer (the one that produces 1000-D softmax input) with your own randomly initialized fully connected layer. If you are interested, have a look at detailed <a href="https://pytorch.org/tutorials/beginner/transfer_learning_tutorial.html" rel="nofollow noreferrer">instructions</a>.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-02-21T10:53:30.810Z
Answers.LastActivityDate: 2019-02-21T10:53:30.810Z
Answers.UserDisplayName: ssegvic
Body: <p>I am confused about how neural networks weigh different features or inputs.</p>
  <p>Consider this example. I have 3 features/inputs: an image, a dollar amount, and a rating.  However, since one feature is an image, I need to represent it with very high dimensionality, for example with <span class="math-container">$128 \times 128 = 16384$</span> pixel values.  (I am just using 'image' as an example, my question holds for any feature that needs high dimensional representation: word counts, one-hot encodings, etc.)</p>
  <p>Will the <span class="math-container">$16384$</span> 'features' representing the image completely overwhelm the other 2 features that are the dollar amount and rating?  Ideally, I would think the network would consider each of the three true features relatively equally.  Would this issue naturally resolve itself in the training process? Would training become much more difficult of a task?</p>
  
Tags: <neural-networks><deep-learning><features>
Title: How do neural networks weigh multiple inputs/features of different dimensionality?
UserDisplayName: Steven Davis
ThreadText: # How do neural networks weigh multiple inputs/features of different dimensionality?
  
  (Asked by: username_0 on 2019-02-20)
  
  I am confused about how neural networks weigh different features or inputs.
  
  Consider this example. I have 3 features/inputs: an image, a dollar amount, and a rating. However, since one feature is an image, I need to represent it with very high dimensionality, for example with $128 \times 128 = 16384$ pixel values. (I am just using 'image' as an example, my question holds for any feature that needs high dimensional representation: word counts, one-hot encodings, etc.)
  
  Will the $16384$ 'features' representing the image completely overwhelm the other 2 features that are the dollar amount and rating? Ideally, I would think the network would consider each of the three true features relatively equally. Would this issue naturally resolve itself in the training process? Would training become much more difficult of a task?
  
  **Tags:** neural-networks, deep-learning, features
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2019-02-21. Score: 1 | Accepted answer
  
  As stated in your example, the three features are: an image, a price, a rating. Now, you want to build a model that uses all of these features and the simplest way to do is to feed them directly into the neural network, but it's inefficient and fundamentally flawed, due to the following reasons:
  
  * In the first dense layer, the neural network will try to combine raw pixel values linearly with price and rating, which will produce features that are meaningless for inference.
  * It could perform well just by optimizing the cost function, but the model performance will be nowhere as good as it could perform with a good architecture.
  
  So, the neural network doesn't care if the data is a raw pixel value, price, or rating: it would just optimize it to produce the desired output. That is why it is necessary to design a suitable architecture for the given problem.
  
  Possible architecture for your given example :
  
  1. Separate your raw features, i.e. pixel value, and high-level data, i.e. price and rating
  2. Stack 2-3 dense layers for raw features (to find complex patterns in images)
  3. Stack 1-2 dense layers for high-level features
  4. Combine them together in a final dense layer
  
  If you want to de-emphasize the importance of the image, just connect the first dense layer 16,384 to another layer having fewer connections, say 1024, and have more connections from the high-level data, say 2048.
  
  So, again, here's the possible architecture
  
  1. Raw features -> dense layer (16384) -> dense layer (1024)
  2. High-level features -> dense layer (2048)
  3. Combine 1 and 2 with another dense layer
  
  
  ---
  
  ### Answer by username_2 on 2019-02-21. Score: 0
  
  The answer by ssh is correct. Your results could be further improved i) by extracting image features by a convolutional (instead of fully connected) architecture, and ii) by exploiting transfer learning.
  
  To exploit transfer learning you i) pick some widely used model, eg. ResNet-18, ii) initialize it with ImageNet pretrained parameters, iii) replace its fully connected layer (the one that produces 1000-D softmax input) with your own randomly initialized fully connected layer. If you are interested, have a look at detailed [instructions](https://pytorch.org/tutorials/beginner/transfer_learning_tutorial.html).
  
  
  ---
  
  