Body: <p>I have my own environment for the DQN algorithm. In my environment, the state space is represented by a list of lists, where each sublist can be of different lengths. In my case, the length of the global list is 300 and the length of each of the sublists varies from 0 to 10. What is the best way to use such state representation as a DQN input if I want to use the PyTorch platform?</p>
  <pre><code>#exapmle state with only 4 sublists and each sublist length can be highest 5
  state = [[1,2,3,4], [1,20,20], [10], [20,4,5,6,7]]
  </code></pre>
  <p>I am thinking of using the raw data with zero(s) at the end of every sublist to make them all of the equal lengths.</p>
  <pre><code>state = [[1,2,3,4,0], [1,20,20,0,0], [10,0,0,0,0], [20,4,5,6,7]]
  </code></pre>
  <p>Then I can convert them to <code>torch.tensor</code> (and maybe flattened) and take that as input in DQN. However, I am wondering - is there a better approach?</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-03-03T09:33:20.820Z
Comments.Text: Note that programming questions are off-topic. To me, this is a "conceptual implementation" question (i.e. it seems to me that you are looking for a general approach to solving this problem), so it's more or less fine, so I will leave it open here for a while.
Comments.UserDisplayName: nbro
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-03-03T16:24:35.293Z
Comments.Text: @nbro, you are correct. That's exactly what I meant. I have slightly edited my question.
Comments.UserDisplayName: nahid
Tags: <reinforcement-learning><dqn><pytorch><state-spaces>
Title: What's the best way to take a list of lists as DQN input?
UserDisplayName: nahid
ThreadText: # What's the best way to take a list of lists as DQN input?
  
  (Asked by: username_0 on 2021-02-27)
  
  I have my own environment for the DQN algorithm. In my environment, the state space is represented by a list of lists, where each sublist can be of different lengths. In my case, the length of the global list is 300 and the length of each of the sublists varies from 0 to 10. What is the best way to use such state representation as a DQN input if I want to use the PyTorch platform?
  
  ```
  #exapmle state with only 4 sublists and each sublist length can be highest 5
  state = [[1,2,3,4], [1,20,20], [10], [20,4,5,6,7]]
  
  ```
  
  I am thinking of using the raw data with zero(s) at the end of every sublist to make them all of the equal lengths.
  
  ```
  state = [[1,2,3,4,0], [1,20,20,0,0], [10,0,0,0,0], [20,4,5,6,7]]
  
  ```
  
  Then I can convert them to `torch.tensor` (and maybe flattened) and take that as input in DQN. However, I am wondering - is there a better approach?
  
  **Tags:** reinforcement-learning, dqn, pytorch, state-spaces
  
  > **Comments:**
  > **username_1**: Note that programming questions are off-topic. To me, this is a "conceptual implementation" question (i.e. it seems to me that you are looking for a general approach to solving this problem), so it's more or less fine, so I will leave it open here for a while.  
  > **username_0**: @username_1, you are correct. That's exactly what I meant. I have slightly edited my question.  
  
  ---
  
  ## 0 answers
  
  