深度学习实验一致性(究极版)

bash 复制代码
import os
import torch
import numpy as np
import random

os.environ["CUBLAS_WORKSPACE_CONFIG"] = ":16:8"
torch.use_deterministic_algorithms(True)



def set_seed(seed_value=42):

    print(seed_value)

    random.seed(seed_value)

    np.random.seed(seed_value)

    torch.manual_seed(seed_value)

    torch.cuda.manual_seed(seed_value)

    torch.cuda.manual_seed_all(seed_value)

    torch.backends.cudnn.deterministic = True

    torch.backends.cudnn.benchmark = False

试了n多次,每次即使设置了随机种子还是会有不一致的结果。感觉可能是因为模型包含写随机操作,使用torch.backends.cudnn.deterministic = True 好像就能解决这个问题,目前影响还没发现

相关推荐
AndrewHZ5 小时前
【AI黑话日日新】什么是AI智能体?
人工智能·算法·语言模型·大模型·llm·ai智能体
cd_949217215 小时前
九昆仑低碳科技:所罗门群岛全国森林碳汇项目开发合作白皮书
大数据·人工智能·科技
工程师老罗5 小时前
目标检测数据标注的工具与使用方法
人工智能·目标检测·计算机视觉
yuankoudaodaokou5 小时前
高校科研新利器:思看科技三维扫描仪助力精密研究
人工智能·python·科技
Acrelhuang5 小时前
工商业用电成本高?安科瑞液冷储能一体机一站式解供能难题-安科瑞黄安南
大数据·开发语言·人工智能·物联网·安全
小王毕业啦5 小时前
2010-2024年 非常规高技能劳动力(+文献)
大数据·人工智能·数据挖掘·数据分析·数据统计·社科数据·经管数据
言無咎6 小时前
从规则引擎到任务规划:AI Agent 重构跨境财税复杂账务处理体系
大数据·人工智能·python·重构
weixin_395448916 小时前
排查流程啊啊啊
人工智能·深度学习·机器学习
Acrelhuang6 小时前
独立监测 + 集团管控 安科瑞连锁餐饮能源方案全链路提效-安科瑞黄安南
人工智能