Closed danghoangnhan closed 1 year ago
你好,這個問題是因為沒有在pytorch的dataset裡面放入dataset能吃的格式,如tensors, numpy arrays, numbers, dicts or lists,但我不確定你是讀到什麼格式了,若是在dataset中放.wav音檔或是pd.DataFrame皆有可能造成此問題。
感謝回覆 On Mon, Jul 10, 2023 at 6:56 PM Chang-Yi Lee @.***> wrote:
你好,這個問題是因為沒有在pytorch的dataset裡面放入dataset能吃的格式,如tensors, numpy arrays, numbers, dicts or lists,但我不確定你是讀到什麼格式了,若是在dataset中放.wav音檔或是pd.DataFrame皆有可能造成此問題。
— Reply to this email directly, view it on GitHub https://github.com/JulianLee310514065/AICUP_audio_2023/issues/1#issuecomment-1628710841, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANWSVACN6WSI35TKFVOVFG3XPPNVFANCNFSM6AAAAAA2EG7TXY . You are receiving this because you modified the open/close state.Message ID: @.***>
我有依照 readme.md 的SOP, 但沒辦法訓練,請問以下的error要怎麼處理
TypeError Traceback (most recent call last) Cell In[12], line 15 12 losses = 0.
14 # training dataset ---> 15 for batch, (mfcc_img, medicals, label, img_path) in enumerate(train_dl): 16 model.train() 18 inputs, medicals, labels = mfcc_img.float().to(device), medicals.float().to(device), label.to(device)
File ~/anaconda3/envs/ai_cup_noise/lib/python3.8/site-packages/torch/utils/data/dataloader.py:681, in _BaseDataLoaderIter.next(self) 678 if self._sampler_iter is None: 679 # TODO(https://github.com/pytorch/pytorch/issues/76750) 680 self._reset() # type: ignore[call-arg] --> 681 data = self._next_data() 682 self._num_yielded += 1 683 if self._dataset_kind == _DatasetKind.Iterable and \ 684 self._IterableDataset_len_called is not None and \ 685 self._num_yielded > self._IterableDataset_len_called:
File ~/anaconda3/envs/ai_cup_noise/lib/python3.8/site-packages/torch/utils/data/dataloader.py:721, in _SingleProcessDataLoaderIter._next_data(self) 719 def _next_data(self): 720 index = self._next_index() # may raise StopIteration --> 721 data = self._dataset_fetcher.fetch(index) # may raise StopIteration 722 if self._pin_memory: 723 data = _utils.pin_memory.pin_memory(data, self._pin_memory_device)
File ~/anaconda3/envs/ai_cup_noise/lib/python3.8/site-packages/torch/utils/data/_utils/fetch.py:52, in _MapDatasetFetcher.fetch(self, possibly_batched_index) 50 else: 51 data = self.dataset[possibly_batched_index] ---> 52 return self.collate_fn(data)
File ~/anaconda3/envs/ai_cup_noise/lib/python3.8/site-packages/torch/utils/data/_utils/collate.py:175, in default_collate(batch) 172 transposed = list(zip(*batch)) # It may be accessed twice, so we use a list. 174 if isinstance(elem, tuple): --> 175 return [default_collate(samples) for samples in transposed] # Backwards compatibility. 176 else: 177 try:
File ~/anaconda3/envs/ai_cup_noise/lib/python3.8/site-packages/torch/utils/data/_utils/collate.py:175, in (.0) 172 transposed = list(zip(*batch)) # It may be accessed twice, so we use a list. 174 if isinstance(elem, tuple): --> 175 return [default_collate(samples) for samples in transposed] # Backwards compatibility. 176 else: 177 try:
File ~/anaconda3/envs/ai_cup_noise/lib/python3.8/site-packages/torch/utils/data/_utils/collate.py:147, in default_collate(batch) 144 if elem_type.name == 'ndarray' or elem_type.name == 'memmap': 145 # array of string classes and object 146 if np_str_obj_array_pattern.search(elem.dtype.str) is not None: --> 147 raise TypeError(default_collate_err_msg_format.format(elem.dtype)) 149 return default_collate([torch.as_tensor(b) for b in batch]) 150 elif elem.shape == (): # scalars
TypeError: default_collate: batch must contain tensors, numpy arrays, numbers, dicts or lists; found object