mirror of
https://github.com/microsoft/qlib.git
synced 2026-07-12 23:36:54 +08:00
Enhance pytorch nn (#917)
* enhance pytorch_nn * fix dim bug * Black format * Fix pylint error
This commit is contained in:
@@ -79,23 +79,14 @@ class TestDataset(TestAutoData):
|
||||
# 3) get both index and data
|
||||
# NOTE: We don't want to reply on pytorch, so this test can't be included. It is just a example
|
||||
from torch.utils.data import DataLoader
|
||||
|
||||
class IdxSampler:
|
||||
def __init__(self, sampler):
|
||||
self.sampler = sampler
|
||||
|
||||
def __getitem__(self, i: int):
|
||||
return self.sampler[i], i
|
||||
|
||||
def __len__(self):
|
||||
return len(self.sampler)
|
||||
from qlib.model.utils import IndexSampler
|
||||
|
||||
i = len(tsds) - 1
|
||||
idx = tsds.get_index()
|
||||
tsds[i]
|
||||
idx[i]
|
||||
|
||||
s_w_i = IdxSampler(tsds)
|
||||
s_w_i = IndexSampler(tsds)
|
||||
test_loader = DataLoader(s_w_i)
|
||||
|
||||
s_w_i[3]
|
||||
|
||||
Reference in New Issue
Block a user