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

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 好像就能解决这个问题,目前影响还没发现

相关推荐
麦豆GEO8 分钟前
本地生活同城服务如何做好GEO优化
人工智能·生活
邂逅and回眸14 分钟前
具身智能入门:机器人是怎么学会干活的
人工智能·机器人
阿里云大数据AI技术1 小时前
SENSER识季 × 阿里云OpenSearch:从时尚灵感到自我表达
人工智能
the3clipse1 小时前
Windows 11 26H2 AI 功能使用指南:回顾、单击以执行与实时字幕
人工智能·windows·copilot+ pc·recall 回顾·单击以执行·实时字幕翻译·windows studio
OpenPie丨拓数派2 小时前
拓数派以产品化FDE基座赋能某世界500强医疗科技企业,打造基于本体论的DRG检验医保合规AI原生服务
人工智能
阿里云大数据AI技术3 小时前
Hologres 数据沙箱:让 AI 在隔离环境中安全探索和验证
人工智能
程序员cxuan3 小时前
Running Hub 上线 Motion
人工智能·aigc
高洁013 小时前
具身智能的人机协作与物理空间安全
人工智能·python·深度学习·机器学习·django
赛博山人4 小时前
Sand.ai发布MAGI-2视频模型
人工智能·音视频
橙序员小站4 小时前
下次放假还有几天?AI开发微信小程序复盘
人工智能·微信小程序