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

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

相关推荐
Aurora-Borealis.4 分钟前
Day27 机器学习流水线
人工智能·机器学习
歌_顿7 分钟前
知识蒸馏学习总结
人工智能·算法
老吴学AI11 分钟前
系列报告九:(埃森哲)The New Rules of Platform Strategy in the Age of Agentic AI
人工智能
棒棒的皮皮13 分钟前
【深度学习】YOLO模型速度优化Checklist
人工智能·深度学习·yolo·计算机视觉
意疏1 小时前
节点小宝4.0 正式发布:一键直达,重新定义远程控制!
人工智能
一个无名的炼丹师1 小时前
GraphRAG深度解析:从原理到实战,重塑RAG检索增强生成的未来
人工智能·python·rag
Yan-英杰1 小时前
BoostKit OmniAdaptor 源码深度解析
网络·人工智能·网络协议·tcp/ip·http
AI街潜水的八角2 小时前
基于Pytorch深度学习神经网络MNIST手写数字识别系统源码(带界面和手写画板)
pytorch·深度学习·神经网络
用泥种荷花2 小时前
【LangChain学习笔记】Message
人工智能
阿里云大数据AI技术2 小时前
一套底座支撑多场景:高德地图基于 Paimon + StarRocks 轨迹服务实践
人工智能