Intra Relational Reasoning, IndexError: tuple index out of range

AP_M: <p>Dear All,</p>
<p>I have uploaded a non image data set where I am trying to break each sample into 3 pieces(piece size 0.2)  and a label to perform intra relational reasoning. But when I the transform_cut under get_item function unable to perform</p>
<pre><code class="lang-auto">class SwelltrainDataset_Intra(T.utils.data.Dataset):

  def __init__(self, Swelltrain, K, transform, transform_cut, **kwds):

    super().__init__(**kwds)
    self.K = K
#    sc = StandardScaler()
    self.transform = transform
#    X_tr = sc.fit_transform(X_train)

    X_tr = X_train
    Y_tr = y_train
    self.X_tr =  X_tr
    self.Y_tr = Y_tr
    self.transform_cut = transform_cut
 #   self.totensor_transform = totensor_transform
 #   self.X_tr = torch.tensor(X_tr, dtype = torch.float32)
 #   self.Y_tr = torch.tensor(Y_tr, dtype = torch.float32)
  def __len__(self):
    return len(self.Y_tr)


  def __getitem__(self, idx):

    X_tr, Y_tr = self.X_tr[idx], self.Y_tr[idx]
    X_tr_list0 = list()
    X_tr_list1 = list()
    Y_tr_list = list()
    if self.transform is not None:
          for _ in range(self.K):

                X_tr_cut0, X_tr_cut1, Y_tr = self.transform_cut(X_tr)
                X_tr_list0.append(X_tr_cut0)
                X_tr_list1.append(X_tr_cut1)
                Y_tr_list.append(Y_tr)

          return X_tr_list0, X_tr_list1, Y_tr_list, Y_tr
</code></pre>
<pre><code class="lang-auto">&lt;ipython-input-24-0b7db19034c5&gt; in train(self, tot_epochs, train_loader)
    41 
    42       # the real target is discarded (unsupervised)
---&gt; 43       for i, (data_augmented0,data_augmented1, data_label, _) in enumerate(train_loader):
    44 
    45         K = len(data_augmented0) # tot augmentations

/usr/local/lib/python3.10/dist-packages/torch/utils/data/dataloader.py in __next__(self)
   631                 # TODO(https://github.com/pytorch/pytorch/issues/76750)
   632                 self._reset()  # type: ignore[call-arg]
--&gt; 633             data = self._next_data()
   634             self._num_yielded += 1
   635             if self._dataset_kind == _DatasetKind.Iterable and \

/usr/local/lib/python3.10/dist-packages/torch/utils/data/dataloader.py in _next_data(self)
   675     def _next_data(self):
   676         index = self._next_index()  # may raise StopIteration
--&gt; 677         data = self._dataset_fetcher.fetch(index)  # may raise StopIteration
   678         if self._pin_memory:
   679             data = _utils.pin_memory.pin_memory(data, self._pin_memory_device)

/usr/local/lib/python3.10/dist-packages/torch/utils/data/_utils/fetch.py in fetch(self, possibly_batched_index)
    49                 data = self.dataset.__getitems__(possibly_batched_index)
    50             else:
---&gt; 51                 data = [self.dataset[idx] for idx in possibly_batched_index]
    52         else:
    53             data = self.dataset[possibly_batched_index]

/usr/local/lib/python3.10/dist-packages/torch/utils/data/_utils/fetch.py in &lt;listcomp&gt;(.0)
    49                 data = self.dataset.__getitems__(possibly_batched_index)
    50             else:
---&gt; 51                 data = [self.dataset[idx] for idx in possibly_batched_index]
    52         else:
    53             data = self.dataset[possibly_batched_index]

&lt;ipython-input-9-e6aebfc9d0eb&gt; in __getitem__(self, idx)
    30           for _ in range(self.K):
    31 
---&gt; 32                 X_tr_cut0, X_tr_cut1, Y_tr = self.transform_cut(X_tr)
    33                 X_tr_list0.append(X_tr_cut0)
    34                 X_tr_list1.append(X_tr_cut1)

&lt;ipython-input-15-d6e9fba82489&gt; in __call__(self, data)
     4 
     5     def __call__(self, data):
----&gt; 6         return self.forward(data)
     7 
     8     def forward(self, data):

&lt;ipython-input-15-d6e9fba82489&gt; in forward(self, data)
     8     def forward(self, data):
     9 
---&gt; 10         return cut_piece3C(data, self.sigma)

&lt;ipython-input-16-cd9459632d6c&gt; in cut_piece3C(ts, perc)
     1 def cut_piece3C(ts, perc=.1):
     2     print("TS_3", ts)
----&gt; 3     seq_len = ts.shape[0]
     4     win_class = seq_len/(2*3)
     5 

IndexError: tuple index out of range
</code></pre>
<p>output values of trainloader 150<br>
TS_3 0.0<br>
As ts value is 0, the sample is not broken properly with no data.</p>

ptrblck: <p>Did you check what <code>ts</code> is and what <code>shape</code> returns? Based on the error message it seems the indexing of <code>shape</code> fails so check what it contains and how to index it.</p>