Code Monkey home page Code Monkey logo

aicup_audio_2023's Issues

TypeError: default_collate: batch must contain tensors, numpy arrays, numbers, dicts or lists; found object

我有依照 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(pytorch/pytorch#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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.