Reshape ndarray in batches for RNN

Viewed 219

targets start from 2 . From given array we took input and target is its next element.Due to shape only till 12 input is coming.I need to reshape the input to array of shape(no of batches,2,2,3) where no of batches is len(text)//(2*2*3) so the no of inputs will be input[:no of batches*2*2*3] convert this [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15] into

    [
      # First Batch
      [
        # Batch of Input
        [[ 1  2  3], [ 7  8  9]],
        # Batch of targets
        [[ 2  3  4], [ 8  9 10]]
      ],

      # Second Batch
      [
        # Batch of Input
        [[ 4  5  6], [10 11 12]],
        # Batch of targets
        [[ 5  6  7], [11 12 13]]
      ]
    ]

targets start from 2 . From given array we took input and target is its next element.Due to shape only till 12 input is coming.I need to reshape the input to array of shape(no of batches,2,2,3) where no of batches is len(text)//(2*2*3) so the no of inputs will be input[:no of batches*2*2*3]

1 Answers
Related