File size: 507 Bytes
c1a46f7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
"""
随机种子管理模块 — 公共模块
"""

import random

import numpy as np
import torch


def set_seed(seed: int = 42):
    """
    设置全局随机种子以确保实验可复现。

    TODO [Person E]:
    1. random.seed(seed)
    2. np.random.seed(seed)
    3. torch.manual_seed(seed)
    4. torch.cuda.manual_seed_all(seed)
    5. torch.backends.cudnn.deterministic = True
    6. torch.backends.cudnn.benchmark = False
    """
    raise NotImplementedError("TODO: Person E 实现 set_seed")