Answers.Body: <p>CNNs have an inductive bias of locality.  They work great on images because squares of inputs often are of an object.  It is a hint to the ML algorithm that very far away pixels should not be considered.  I can't confirm that CNN is wrong here but unless there is some locality to these machine attributes it may be more work than it's worth.</p>
  <p>I would likely keep it dense, the values all get considered against each other in a dense layer anyway.  To consider history it is then natural to convolute with history or LSTM, GRU, etc.</p>
  <p>It is of course possible to try and force locality by grouping inputs into multiple unconnected dense networks and then merging them at a later layer.  Hinting can sometimes help but unless one knows of something specific it may be best to leave it simple.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-03-18T14:38:37.203Z
Answers.LastActivityDate: 2024-03-18T14:44:24.807Z
Answers.LastEditDate: 2024-03-18T14:44:24.807Z
Answers.UserDisplayName: foreverska
Body: <p><strong>Context:</strong> I want to build a DQN with as CNN for calculating its Q value on each step.</p>
  <p>Enviroment's status can be described by the attributes of 3 machines (each one with own attributes). I'd also like to add some history of recent readings so DQN can understand what is happenening and not only a picture of current readings.</p>
  <p>Let's say machine <code>A</code>, <code>B</code> and <code>C</code> have attributes <code>{a1, a2, a3}</code>, <code>{b1, b2, b3}</code>  and <code>{c1, c2}</code></p>
  <p>I want to pass the last n reads. So CNN input should have something like:</p>
  <pre><code>[
      [[a_11, a_12, a_13], [b_11, b_12, b_13], [c_11, c_12]],
      [[a_21, a_22, a_23], [b_21, b_22, b_23], [c_21, c_22]],
      ...
      [[a_n1, a_n2, a_n3], [b_n1, b_n2, b_n3], [c_n1, c_n2]]
  ]
  </code></pre>
  <p><strong>Problem:</strong> I can't figure out how to represent this in a matrix because different machines have different amount of attributes</p>
  <p><strong>My thoughts:</strong></p>
  <ul>
  <li>Each machine is a 1 dimension vector</li>
  <li>3 machines can be interpreted in a 2D CNN. But not all machines are the same length...</li>
  <li>As 2D does not work, 3D CNN by adding time will not work as well</li>
  </ul>
  <p><strong>Suboptimal solution idea:</strong></p>
  <ul>
  <li>Flatten all machine attributes to a single read as <code>[a1, a2, a3, b1, ..., c2]</code></li>
  <li>Make it 2D with time</li>
  <li>Use 2D CNN with convolusional operations work in columns (not between them).</li>
  </ul>
  <p><strong>Questions:</strong></p>
  <ol>
  <li>Any better way to organize CNN input?</li>
  <li>Maybe other kind of NN to estimate Q-Values is a better fit in this case?</li>
  </ol>
  
Tags: <deep-learning><convolutional-neural-networks><deep-rl><dqn>
Title: CNN Input shape for DQN Q-calculating Network
UserDisplayName: Oliver Mohr Bonometti
ThreadText: # CNN Input shape for DQN Q-calculating Network
  
  (Asked by: username_0 on 2024-03-16)
  
  **Context:** I want to build a DQN with as CNN for calculating its Q value on each step.
  
  Enviroment's status can be described by the attributes of 3 machines (each one with own attributes). I'd also like to add some history of recent readings so DQN can understand what is happenening and not only a picture of current readings.
  
  Let's say machine `A`, `B` and `C` have attributes `{a1, a2, a3}`, `{b1, b2, b3}` and `{c1, c2}`
  
  I want to pass the last n reads. So CNN input should have something like:
  
  ```
  [
      [[a_11, a_12, a_13], [b_11, b_12, b_13], [c_11, c_12]],
      [[a_21, a_22, a_23], [b_21, b_22, b_23], [c_21, c_22]],
      ...
      [[a_n1, a_n2, a_n3], [b_n1, b_n2, b_n3], [c_n1, c_n2]]
  ]
  
  ```
  
  **Problem:** I can't figure out how to represent this in a matrix because different machines have different amount of attributes
  
  **My thoughts:**
  
  * Each machine is a 1 dimension vector
  * 3 machines can be interpreted in a 2D CNN. But not all machines are the same length...
  * As 2D does not work, 3D CNN by adding time will not work as well
  
  **Suboptimal solution idea:**
  
  * Flatten all machine attributes to a single read as `[a1, a2, a3, b1, ..., c2]`
  * Make it 2D with time
  * Use 2D CNN with convolusional operations work in columns (not between them).
  
  **Questions:**
  
  1. Any better way to organize CNN input?
  2. Maybe other kind of NN to estimate Q-Values is a better fit in this case?
  
  **Tags:** deep-learning, convolutional-neural-networks, deep-rl, dqn
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2024-03-18. Score: 2
  
  CNNs have an inductive bias of locality. They work great on images because squares of inputs often are of an object. It is a hint to the ML algorithm that very far away pixels should not be considered. I can't confirm that CNN is wrong here but unless there is some locality to these machine attributes it may be more work than it's worth.
  
  I would likely keep it dense, the values all get considered against each other in a dense layer anyway. To consider history it is then natural to convolute with history or LSTM, GRU, etc.
  
  It is of course possible to try and force locality by grouping inputs into multiple unconnected dense networks and then merging them at a later layer. Hinting can sometimes help but unless one knows of something specific it may be best to leave it simple.
  
  
  ---
  
  