Pārlūkot izejas kodu

speed-reproducibility fix #17

5.0
Glenn Jocher pirms 4 gadiem
vecāks
revīzija
22d6088205
2 mainītis faili ar 6 papildinājumiem un 3 dzēšanām
  1. +1
    -1
      train.py
  2. +5
    -2
      utils/torch_utils.py

+ 1
- 1
train.py Parādīt failu

@@ -63,7 +63,7 @@ def train(hyp):
weights = opt.weights # initial training weights

# Configure
init_seeds()
init_seeds(1)
with open(opt.data) as f:
data_dict = yaml.load(f, Loader=yaml.FullLoader) # model dict
train_path = data_dict['train']

+ 5
- 2
utils/torch_utils.py Parādīt failu

@@ -12,8 +12,11 @@ import torch.nn.functional as F
def init_seeds(seed=0):
torch.manual_seed(seed)

# Reduce randomness (may be slower on Tesla GPUs) # https://pytorch.org/docs/stable/notes/randomness.html
if seed == 0:
# Speed-reproducibility tradeoff https://pytorch.org/docs/stable/notes/randomness.html
if seed == 0: # slower, more reproducible
cudnn.deterministic = True
cudnn.benchmark = False
else: # faster, less reproducible
cudnn.deterministic = False
cudnn.benchmark = True


Notiek ielāde…
Atcelt
Saglabāt