You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Thanks for your amazing work! I have a question about the SBI dataloader : Are the SBI images kept the same within different epochs? In the source code, the worker_init_fn function is set to :np.random.seed(np.random.get_state()[1][0] + worker_id)
And I found that when num_workers > 0 , the np.random.get_state() of each worker in different epochs is the same. So the random numbers output by dataloader in different epochs is the same, does that means the SBI dataset kept the same in the training phase? Demo code is below:
import torch
from torch.utils.data import Dataset
import numpy as np
import random
class TestDataset(Dataset):
def __init__(self):
self.datas = np.arange(16)
print('init')
def __len__(self):
return len(self.datas)
def __getitem__(self, index):
data = self.datas[index]
random_data = np.random.uniform(0.0, 1.0)
return data, random_data
def worker_init_fn(self, worker_id):
np.random.seed(np.random.get_state()[1][0] + worker_id)
if __name__ == '__main__':
simple_dataset = TestDataset()
dataloader = torch.utils.data.DataLoader(simple_dataset,
batch_size=2,
shuffle=True,
worker_init_fn=simple_dataset.worker_init_fn,
num_workers=2)
n_epoch = 3
seed = 5
torch.manual_seed(seed)
np.random.seed(seed)
random.seed(seed)
for epoch in range(n_epoch):
print('epoch_%d'%epoch)
np.random.seed(seed + epoch)
for step, data in enumerate(dataloader):
print(data)
Thanks for your amazing work! I have a question about the SBI dataloader : Are the SBI images kept the same within different epochs? In the source code, the
worker_init_fn
function is set to :np.random.seed(np.random.get_state()[1][0] + worker_id)
And I found that when
num_workers > 0
, thenp.random.get_state()
of each worker in different epochs is the same. So the random numbers output by dataloader in different epochs is the same, does that means the SBI dataset kept the same in the training phase? Demo code is below:And the output is :
The text was updated successfully, but these errors were encountered: