File size: 742 Bytes
1d5604f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import random
import torch
import os


def seed_everything(seed_value=42):
    os.environ['PYTHONHASHSEED'] = str(seed_value)
    random.seed(seed_value)
    torch.manual_seed(seed_value)
    torch.cuda.manual_seed_all(seed_value)

    torch.backends.cudnn.enabled = True
    torch.backends.cudnn.deterministic = True
    torch.backends.cudnn.benchmark = False


def initialize(args, init_wandb: bool):
    seed_everything(args.seed)

    if init_wandb:
        import wandb
        tags = args.framework, args.language
        wandb.init(name=f"{args.framework}_{args.language}_{args.graph_mode}_{args.name}", config=args, project="sentiment_graphs", tags=list(tags))
        print("Connection to Weights & Biases initialized.", flush=True)