[d6904d]: / app / core / utils / random.py

Download this file

22 lines (18 with data), 429 Bytes

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
import argparse
import copy
import datetime
import imp
import math
import os
import pickle
import random
import re
import numpy as np
import torch
def init_random(seed):
np.random.seed(seed) # numpy
random.seed(seed)
torch.manual_seed(seed) # cpu
torch.cuda.manual_seed(seed) # gpu
torch.backends.cudnn.deterministic = True # cudnn
np.set_printoptions(threshold=np.inf, precision=2, suppress=True)