Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

代码报错 #2

Open
shuqincao opened this issue Mar 27, 2022 · 0 comments
Open

代码报错 #2

shuqincao opened this issue Mar 27, 2022 · 0 comments

Comments

@shuqincao
Copy link

代码运行到“HZMetro.py”的146行的“ rest_ind = self.restday.loc[dates].to_numpy().flatten().astype(np.int64) # 0: workday, 1: restday”报错

报错详情如下:
---------- Training ----------
num_samples: 1188, num_batches: 594
0%| | 0/594 [00:00<?, ?it/s]Traceback (most recent call last):
File "F:/orginalCode/MGT-main/main.py", line 236, in
train(args, logger)
File "F:/orginalCode/MGT-main/main.py", line 156, in train
criterion, optimizer, scheduler, args)
File "F:/orginalCode/MGT-main/main.py", line 86, in train_epoch
for batch in tqdm(train_loader):
File "D:\programfiles\Anaconda3\lib\site-packages\tqdm\std.py", line 1107, in iter
for obj in iterable:
File "D:\programfiles\Anaconda3\lib\site-packages\torch\utils\data\dataloader.py", line 435, in next
data = self._next_data()
File "D:\programfiles\Anaconda3\lib\site-packages\torch\utils\data\dataloader.py", line 1085, in _next_data
return self._process_data(data)
File "D:\programfiles\Anaconda3\lib\site-packages\torch\utils\data\dataloader.py", line 1111, in _process_data
data.reraise()
File "D:\programfiles\Anaconda3\lib\site-packages\torch_utils.py", line 428, in reraise
raise self.exc_type(msg)
KeyError: Caught KeyError in DataLoader worker process 0.
Original Traceback (most recent call last):
File "D:\programfiles\Anaconda3\lib\site-packages\torch\utils\data_utils\worker.py", line 198, in _worker_loop
data = fetcher.fetch(index)
File "D:\programfiles\Anaconda3\lib\site-packages\torch\utils\data_utils\fetch.py", line 44, in fetch
data = [self.dataset[idx] for idx in possibly_batched_index]
File "D:\programfiles\Anaconda3\lib\site-packages\torch\utils\data_utils\fetch.py", line 44, in
data = [self.dataset[idx] for idx in possibly_batched_index]
File "F:\orginalCode\MGT-main\datasets\HZMetro.py", line 62, in getitem
inputs_rest = self.rest_transform(self.data['xtime'][item])
File "F:\orginalCode\MGT-main\datasets\HZMetro.py", line 146, in rest_transform
rest_ind = self.restday.loc[dates].to_numpy().flatten().astype(np.int64) # 0: workday, 1: restday
File "D:\programfiles\Anaconda3\lib\site-packages\pandas\core\indexing.py", line 1767, in getitem
return self._getitem_axis(maybe_callable, axis=axis)
File "D:\programfiles\Anaconda3\lib\site-packages\pandas\core\indexing.py", line 1953, in _getitem_axis
return self._getitem_iterable(key, axis=axis)
File "D:\programfiles\Anaconda3\lib\site-packages\pandas\core\indexing.py", line 1594, in _getitem_iterable
keyarr, indexer = self._get_listlike_indexer(key, axis, raise_missing=False)
File "D:\programfiles\Anaconda3\lib\site-packages\pandas\core\indexing.py", line 1552, in _get_listlike_indexer
keyarr, indexer, o._get_axis_number(axis), raise_missing=raise_missing
File "D:\programfiles\Anaconda3\lib\site-packages\pandas\core\indexing.py", line 1639, in _validate_read_indexer
raise KeyError(f"None of [{key}] are in the [{axis_name}]")
KeyError: "None of [Index(['2019-01-02', '2019-01-02', '2019-01-02', '2019-01-02'], dtype='object', name='time')] are in the [index]"

0%| | 0/594 [00:12<?, ?it/s]

Process finished with exit code 1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant