Only do numpy seeding if numpy seed is not fixed, fix regression introduced by
@@ -21,6 +21,7 @@ import kge.job.util
SLOTS = [0, 1, 2]
S, P, O = SLOTS
+
def _worker_init_fn(worker_num):
# ensure that NumPy uses different seeds at each worker
np.random.seed()
@@ -595,7 +596,9 @@ class TrainingJobKvsAll(TrainingJob):
shuffle=True,
batch_size=self.batch_size,
num_workers=self.config.get("train.num_workers"),
- worker_init_fn=_worker_init_fn,
+ worker_init_fn=_worker_init_fn
+ if self.config.get("random_seed.numpy") == -1
+ else None,
pin_memory=self.config.get("train.pin_memory"),
)
@@ -803,7 +806,9 @@ class TrainingJobNegativeSampling(TrainingJob):
shuffle=True,
batch_size=self.batch_size,
num_workers=self.config.get("train.num_workers"),
- worker_init_fn=_worker_init_fn,
+ worker_init_fn=_worker_init_fn
+ if self.config.get("random_seed.numpy") == -1
+ else None,
pin_memory=self.config.get("train.pin_memory"),
)
@@ -1038,7 +1043,9 @@ class TrainingJob1vsAll(TrainingJob):
shuffle=True,
batch_size=self.batch_size,
num_workers=self.config.get("train.num_workers"),
- worker_init_fn=_worker_init_fn,
+ worker_init_fn=_worker_init_fn
+ if self.config.get("random_seed.numpy") == -1
+ else None,
pin_memory=self.config.get("train.pin_memory"),
)
