No error, but it is not executed

ran_ran1: <p>I am new here and I’m new to using the torch library for autoencoders</p>
<p>I want to implement a pre-written code with the same dataset used. There are no errors, but it is not executed. When I track the execution it seems that it is stuck in this loop(for batch_idx, (batch_data, batch_index) in enumerate(zip(input_trainLoader, pad_index_trainLoader))<img src="https://discuss.pytorch.org/images/emoji/apple/slight_smile.png?v=12" title=":slight_smile:" class="emoji" alt=":slight_smile:" loading="lazy" width="20" height="20"> …</p>
<p>I waited 4 hours for it to complete the first cycle but nothing happened…what should I do…hope for help</p>
<p><div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/6/2/620d29902f47df26b56f833dd1cfab833c8f1f5f.png" data-download-href="https://discuss.pytorch.org/uploads/default/620d29902f47df26b56f833dd1cfab833c8f1f5f" title="Capture1"><img src="https://discuss.pytorch.org/uploads/default/original/3X/6/2/620d29902f47df26b56f833dd1cfab833c8f1f5f.png" alt="Capture1" data-base62-sha1="dZoZwud7kKRnbNo6gzWqI1FWVIP" width="690" height="323" data-dominant-color="FAFAFA"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">Capture1</span><span class="informations">1099×516 19.7 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div></p>
<p>I can not upload other pictures because I am new , should put the link for whole code?</p>

ptrblck: <p>If you are using multiprocessing in your <code>DataLoader</code>s, try to use the main process only for debugging via <code>num_workers=0</code> and see if your code doesn’t hang anymore.</p>

ran_ran1: <p>Hi,<br>
I put num_workers=0 instead of num_workers=2,in the following rows:<br>
input_trainLoader = torch.utils.data.DataLoader(input_train, batch_size=args.batch_size, shuffle=False, num_workers=0)<br>
print(args.batch_size)<span class="hashtag">#16</span><br>
pad_index_trainLoader = torch.utils.data.DataLoader(pad_index_train, batch_size=args.batch_size, shuffle=False, num_workers=0)</p>
<p>but I get the following error</p>
<p>Traceback (most recent call last):<br>
File “C:\Users\Admin\AppData\Local\Programs\Python\Python310\multivariate anomaly detection for evnt logs\AE.py”, line 206, in <br>
train_loss = train(epoch, model, optimizer)<br>
File “C:\Users\Admin\AppData\Local\Programs\Python\Python310\multivariate anomaly detection for evnt logs\AE.py”, line 172, in train<br>
for batch_idx, (batch_data, batch_index) in enumerate(zip(input_trainLoader, pad_index_trainLoader)):<br>
File “C:\Users\Admin\AppData\Local\Programs\Python\Python310\lib\site-packages\torch\utils\data\dataloader.py”, line 681, in <strong>next</strong><br>
data = self._next_data()<br>
File “C:\Users\Admin\AppData\Local\Programs\Python\Python310\lib\site-packages\torch\utils\data\dataloader.py”, line 721, in _next_data<br>
data = self._dataset_fetcher.fetch(index)  # may raise StopIteration<br>
File “C:\Users\Admin\AppData\Local\Programs\Python\Python310\lib\site-packages\torch\utils\data_utils\fetch.py”, line 52, in fetch<br>
return self.collate_fn(data)<br>
File “C:\Users\Admin\AppData\Local\Programs\Python\Python310\lib\site-packages\torch\utils\data_utils\collate.py”, line 147, in default_collate<br>
raise TypeError(default_collate_err_msg_format.format(elem.dtype))<br>
TypeError: default_collate: batch must contain tensors, numpy arrays, numbers, dicts or lists; found object</p>
<p>can I get help</p>

ptrblck: <aside class="quote no-group" data-username="ran_ran1" data-post="3" data-topic="161578">
<div class="title">
<div class="quote-controls"></div>
<img loading="lazy" alt="" width="24" height="24" src="https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/ran_ran1/48/46541_2.png" class="avatar"> ran_ran1:</div>
<blockquote>
<p>TypeError: default_collate: batch must contain tensors, numpy arrays, numbers, dicts or lists; found object</p>
</blockquote>
</aside>
<p>Your <code>Dataset.__getitem__</code> doesn’t seem to return any supported type, but <code>object"</code>s.<br>
Check the type of all returned values and make sure they are one of the mentioned supported types.</p>

ran_ran1: <p>I am sorry if the Question Might Seems Obvious or Dumb but I am new to autoencoders:<br>
I can not find <code>.__getitem__</code> I do not know where to find it in the pre_written code or maybe it does not exist</p>
<p>I searched for this error I found that solution:<br>
transform = transforms.Compose([<br>
transforms.ToTensor()<br>
])<br>
tnew=transform(input_train)<br>
<span class="hashtag-raw">#train</span><br>
input_trainLoader = torch.utils.data.DataLoader(tnew, batch_size=args.batch_size, shuffle=False, num_workers=0)</p>
<p>but I got this error:<br>
TypeError: can’t convert np.ndarray of type numpy.object_. The only supported types are: float64, float32, float16, complex64, complex128, int64, int32, int16, int8, uint8, and bool.</p>
<p>I fixed this error as following:<br>
transform = transforms.Compose([<br>
transforms.ToTensor()<br>
])<br>
tt=np.vstack(input_train).astype(float)<br>
tnew=transform(tt)<br>
<span class="hashtag-raw">#train</span><br>
input_trainLoader = torch.utils.data.DataLoader(tnew, batch_size=args.batch_size, shuffle=False, num_workers=0)</p>
<p>but I returned to the first error<br>
this is my input_train<br>
<div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/1/4/14dfc049b6efa60e04d3ef0119ea60761972ddd4.png" data-download-href="https://discuss.pytorch.org/uploads/default/14dfc049b6efa60e04d3ef0119ea60761972ddd4" title="Capture4"><img src="https://discuss.pytorch.org/uploads/default/original/3X/1/4/14dfc049b6efa60e04d3ef0119ea60761972ddd4.png" alt="Capture4" data-base62-sha1="2YEVUehZLYKf6R9FlO80nDwvTBq" width="291" height="500" data-dominant-color="F9F9FF"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">Capture4</span><span class="informations">546×938 9.15 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div><br>
and this is the output<br>
input_trainLoader = torch.utils.data.DataLoader(tnew, batch_size=args.batch_size, shuffle=False, num_workers=0)##<span class="hashtag-raw">#object</span><br>
print(args.batch_size)<span class="hashtag-raw">#16</span><br>
print(input_trainLoader)#&lt;torch.utils.data.dataloader.DataLoader object at 0x000001B93DD52680&gt;</p>
<p>pad_index_trainLoader = torch.utils.data.DataLoader(pad_index_train, batch_size=args.batch_size, shuffle=False, num_workers=0)</p>
<p>print(pad_index_trainLoader)#&lt;torch.utils.data.dataloader.DataLoader object at 0x000001B93DD524D0&gt;</p>