首页 > 解决方案 > Google Colab - NotImplementedError

问题描述

我一直在尝试使用以下包,就在我尝试实例化它时,它NotImplementedError:出现在 Google Colab 中。

问题的完整追溯

<ipython-input-51-9980be5d7f5b> in <module>()
      4 test_dataset = MyData(input_tensor_test, target_tensor_test)
      5 
----> 6 train_dataset = DataLoader(train_dataset, sampler=ImbalancedDatasetSampler(train_dataset),batch_size = BATCH_SIZE, 
      7                      drop_last=True
      8                      )

1 frames
/content/drive/My Drive/torchsampler/imbalanced.py in __init__(self, dataset, indices, num_samples, callback_get_label)
     30         label_to_count = {}
     31         for idx in self.indices:
---> 32             label = self._get_label(dataset, idx)
     33             if label in label_to_count:
     34                 label_to_count[label] += 1

/content/drive/My Drive/torchsampler/imbalanced.py in _get_label(self, dataset, idx)
     51             return self.callback_get_label(dataset, idx)
     52         else:
---> 53             raise NotImplementedError
     54 
     55     def __iter__(self):

NotImplementedError: 

我见过类似的解决方案来解决这个问题,但它是在 jupyter notebook 中提出的解决方案包括升级笔记本。

我如何在 Colab 中解决此问题,或者是否有其他替代方法可以在 Colab 上解决此问题?

标签: pythongoogle-colaboratory

解决方案


推荐阅读