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

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

相关推荐
AI周红伟10 小时前
周红伟:智能体全栈构建实操:OpenClaw部署+Agent Skills+Seedance+RAG从入门到实战
大数据·人工智能·大模型·智能体
Wishell201510 小时前
人工智能中卷积
人工智能
多恩Stone10 小时前
【C++入门扫盲1】C++ 与 Python:类型、编译器/解释器与 CPU 的关系
开发语言·c++·人工智能·python·算法·3d·aigc
生信大杂烩10 小时前
癌症中的“细胞邻域“:解码肿瘤微环境的空间密码 ——Nature Cancer 综述解读
人工智能·算法
修炼前端秘籍的小帅10 小时前
Stitch——Google热门的免费AI UI设计工具
前端·人工智能·ui
ccLianLian10 小时前
强化学习·导论
深度学习
B站_计算机毕业设计之家10 小时前
电影知识图谱推荐问答系统 | Python Django系统 Neo4j MySQL Echarts 协同过滤 大数据 人工智能 毕业设计源码(建议收藏)✅
人工智能·python·机器学习·django·毕业设计·echarts·知识图谱
小马_xiaoen10 小时前
🔥AI Prompt 工程完全指南:从入门到精通的提示词设计艺术
人工智能
爱吃的小肥羊10 小时前
DeepSeek V4 细节曝光:100 万上下文 + 原生多模态
人工智能·aigc·deepseek
zhangfeng113310 小时前
趋动云 如何ssh登录 服务区 项目server
运维·人工智能·ssh