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

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

相关推荐
V哥AI增长几秒前
小红书笔记在生成式AI引擎中的可见性机制解析:从抓取原理到GEO工程化实践
大数据·人工智能·笔记
ajassi200020 分钟前
AI语音智能体开发日记(十二)GX8006 固件定制指南——从双唤醒词到 UART 音频传输
人工智能·ai·ai编程
大模型momo26 分钟前
告别单体 Agent:多智能体设计模式(Multi-Agent Patterns)深度实战手册
人工智能·agent·multi-agent·多agent
DisonTangor35 分钟前
【SeeDream开源平替】MiniMax H3 重磅开源:全模态视频生成新标杆,2K 画质 + 原生立体声,15 秒大片一键生成!
人工智能·ai作画·开源·aigc·音视频
很楠爱上1 小时前
(附上相关学习资源)适合新手做的第一个agent项目*ovo*Dify Agent 全栈实战:从智能选车顾问到新能源汽车之家的端到端开发
人工智能·汽车·agent·项目·开发笔记
IT智慧客07311 小时前
2026年7月前端面试高频考点与趋势分析(面20个前端后的总结)
人工智能
不瘦80斤不改名1 小时前
01-vibe-coding-起源与本质
人工智能·python
冬奇Lab1 小时前
代码库知识库系列(08):生产级架构设计——向量、图、符号索引如何组合
人工智能
冬奇Lab1 小时前
开源项目第177期:Apache Airflow — 用 Python 写出来的工作流调度器,数据工程师的标配工具
人工智能·开源·资讯