Skip to content

Commit

Permalink
set seed at multiprocessing iterator
Browse files Browse the repository at this point in the history
  • Loading branch information
Hiroshiba committed May 15, 2021
1 parent a395291 commit 893356c
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pytorch_trainer/iterators/multiprocess_iterator.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import numpy
import six
import torch

from pytorch_trainer.dataset import iterator
from pytorch_trainer.iterators import _statemachine
Expand Down Expand Up @@ -554,6 +555,9 @@ def _fetch_setup(dataset, mem_size, mem_bulk):
_fetch_mem_size = mem_size
_fetch_mem_bulk = mem_bulk

numpy.random.seed(multiprocessing.current_process().pid)
torch.manual_seed(multiprocessing.current_process().pid)


def _fetch_run(inputs):
i, index = inputs
Expand Down

0 comments on commit 893356c

Please sign in to comment.