[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"similar-dougbrion--pytorch-classification-uncertainty":3,"tool-dougbrion--pytorch-classification-uncertainty":64},[4,17,27,35,43,56],{"id":5,"name":6,"github_repo":7,"description_zh":8,"stars":9,"difficulty_score":10,"last_commit_at":11,"category_tags":12,"status":16},3808,"stable-diffusion-webui","AUTOMATIC1111\u002Fstable-diffusion-webui","stable-diffusion-webui 是一个基于 Gradio 构建的网页版操作界面，旨在让用户能够轻松地在本地运行和使用强大的 Stable Diffusion 图像生成模型。它解决了原始模型依赖命令行、操作门槛高且功能分散的痛点，将复杂的 AI 绘图流程整合进一个直观易用的图形化平台。\n\n无论是希望快速上手的普通创作者、需要精细控制画面细节的设计师，还是想要深入探索模型潜力的开发者与研究人员，都能从中获益。其核心亮点在于极高的功能丰富度：不仅支持文生图、图生图、局部重绘（Inpainting）和外绘（Outpainting）等基础模式，还独创了注意力机制调整、提示词矩阵、负向提示词以及“高清修复”等高级功能。此外，它内置了 GFPGAN 和 CodeFormer 等人脸修复工具，支持多种神经网络放大算法，并允许用户通过插件系统无限扩展能力。即使是显存有限的设备，stable-diffusion-webui 也提供了相应的优化选项，让高质量的 AI 艺术创作变得触手可及。",162132,3,"2026-04-05T11:01:52",[13,14,15],"开发框架","图像","Agent","ready",{"id":18,"name":19,"github_repo":20,"description_zh":21,"stars":22,"difficulty_score":23,"last_commit_at":24,"category_tags":25,"status":16},1381,"everything-claude-code","affaan-m\u002Feverything-claude-code","everything-claude-code 是一套专为 AI 编程助手（如 Claude Code、Codex、Cursor 等）打造的高性能优化系统。它不仅仅是一组配置文件，而是一个经过长期实战打磨的完整框架，旨在解决 AI 代理在实际开发中面临的效率低下、记忆丢失、安全隐患及缺乏持续学习能力等核心痛点。\n\n通过引入技能模块化、直觉增强、记忆持久化机制以及内置的安全扫描功能，everything-claude-code 能显著提升 AI 在复杂任务中的表现，帮助开发者构建更稳定、更智能的生产级 AI 代理。其独特的“研究优先”开发理念和针对 Token 消耗的优化策略，使得模型响应更快、成本更低，同时有效防御潜在的攻击向量。\n\n这套工具特别适合软件开发者、AI 研究人员以及希望深度定制 AI 工作流的技术团队使用。无论您是在构建大型代码库，还是需要 AI 协助进行安全审计与自动化测试，everything-claude-code 都能提供强大的底层支持。作为一个曾荣获 Anthropic 黑客大奖的开源项目，它融合了多语言支持与丰富的实战钩子（hooks），让 AI 真正成长为懂上",138956,2,"2026-04-05T11:33:21",[13,15,26],"语言模型",{"id":28,"name":29,"github_repo":30,"description_zh":31,"stars":32,"difficulty_score":23,"last_commit_at":33,"category_tags":34,"status":16},2271,"ComfyUI","Comfy-Org\u002FComfyUI","ComfyUI 是一款功能强大且高度模块化的视觉 AI 引擎，专为设计和执行复杂的 Stable Diffusion 图像生成流程而打造。它摒弃了传统的代码编写模式，采用直观的节点式流程图界面，让用户通过连接不同的功能模块即可构建个性化的生成管线。\n\n这一设计巧妙解决了高级 AI 绘图工作流配置复杂、灵活性不足的痛点。用户无需具备编程背景，也能自由组合模型、调整参数并实时预览效果，轻松实现从基础文生图到多步骤高清修复等各类复杂任务。ComfyUI 拥有极佳的兼容性，不仅支持 Windows、macOS 和 Linux 全平台，还广泛适配 NVIDIA、AMD、Intel 及苹果 Silicon 等多种硬件架构，并率先支持 SDXL、Flux、SD3 等前沿模型。\n\n无论是希望深入探索算法潜力的研究人员和开发者，还是追求极致创作自由度的设计师与资深 AI 绘画爱好者，ComfyUI 都能提供强大的支持。其独特的模块化架构允许社区不断扩展新功能，使其成为当前最灵活、生态最丰富的开源扩散模型工具之一，帮助用户将创意高效转化为现实。",107662,"2026-04-03T11:11:01",[13,14,15],{"id":36,"name":37,"github_repo":38,"description_zh":39,"stars":40,"difficulty_score":23,"last_commit_at":41,"category_tags":42,"status":16},3704,"NextChat","ChatGPTNextWeb\u002FNextChat","NextChat 是一款轻量且极速的 AI 助手，旨在为用户提供流畅、跨平台的大模型交互体验。它完美解决了用户在多设备间切换时难以保持对话连续性，以及面对众多 AI 模型不知如何统一管理的痛点。无论是日常办公、学习辅助还是创意激发，NextChat 都能让用户随时随地通过网页、iOS、Android、Windows、MacOS 或 Linux 端无缝接入智能服务。\n\n这款工具非常适合普通用户、学生、职场人士以及需要私有化部署的企业团队使用。对于开发者而言，它也提供了便捷的自托管方案，支持一键部署到 Vercel 或 Zeabur 等平台。\n\nNextChat 的核心亮点在于其广泛的模型兼容性，原生支持 Claude、DeepSeek、GPT-4 及 Gemini Pro 等主流大模型，让用户在一个界面即可自由切换不同 AI 能力。此外，它还率先支持 MCP（Model Context Protocol）协议，增强了上下文处理能力。针对企业用户，NextChat 提供专业版解决方案，具备品牌定制、细粒度权限控制、内部知识库整合及安全审计等功能，满足公司对数据隐私和个性化管理的高标准要求。",87618,"2026-04-05T07:20:52",[13,26],{"id":44,"name":45,"github_repo":46,"description_zh":47,"stars":48,"difficulty_score":23,"last_commit_at":49,"category_tags":50,"status":16},2268,"ML-For-Beginners","microsoft\u002FML-For-Beginners","ML-For-Beginners 是由微软推出的一套系统化机器学习入门课程，旨在帮助零基础用户轻松掌握经典机器学习知识。这套课程将学习路径规划为 12 周，包含 26 节精炼课程和 52 道配套测验，内容涵盖从基础概念到实际应用的完整流程，有效解决了初学者面对庞大知识体系时无从下手、缺乏结构化指导的痛点。\n\n无论是希望转型的开发者、需要补充算法背景的研究人员，还是对人工智能充满好奇的普通爱好者，都能从中受益。课程不仅提供了清晰的理论讲解，还强调动手实践，让用户在循序渐进中建立扎实的技能基础。其独特的亮点在于强大的多语言支持，通过自动化机制提供了包括简体中文在内的 50 多种语言版本，极大地降低了全球不同背景用户的学习门槛。此外，项目采用开源协作模式，社区活跃且内容持续更新，确保学习者能获取前沿且准确的技术资讯。如果你正寻找一条清晰、友好且专业的机器学习入门之路，ML-For-Beginners 将是理想的起点。",84991,"2026-04-05T10:45:23",[14,51,52,53,15,54,26,13,55],"数据工具","视频","插件","其他","音频",{"id":57,"name":58,"github_repo":59,"description_zh":60,"stars":61,"difficulty_score":10,"last_commit_at":62,"category_tags":63,"status":16},3128,"ragflow","infiniflow\u002Fragflow","RAGFlow 是一款领先的开源检索增强生成（RAG）引擎，旨在为大语言模型构建更精准、可靠的上下文层。它巧妙地将前沿的 RAG 技术与智能体（Agent）能力相结合，不仅支持从各类文档中高效提取知识，还能让模型基于这些知识进行逻辑推理和任务执行。\n\n在大模型应用中，幻觉问题和知识滞后是常见痛点。RAGFlow 通过深度解析复杂文档结构（如表格、图表及混合排版），显著提升了信息检索的准确度，从而有效减少模型“胡编乱造”的现象，确保回答既有据可依又具备时效性。其内置的智能体机制更进一步，使系统不仅能回答问题，还能自主规划步骤解决复杂问题。\n\n这款工具特别适合开发者、企业技术团队以及 AI 研究人员使用。无论是希望快速搭建私有知识库问答系统，还是致力于探索大模型在垂直领域落地的创新者，都能从中受益。RAGFlow 提供了可视化的工作流编排界面和灵活的 API 接口，既降低了非算法背景用户的上手门槛，也满足了专业开发者对系统深度定制的需求。作为基于 Apache 2.0 协议开源的项目，它正成为连接通用大模型与行业专有知识之间的重要桥梁。",77062,"2026-04-04T04:44:48",[15,14,13,26,54],{"id":65,"github_repo":66,"name":67,"description_en":68,"description_zh":69,"ai_summary_zh":70,"readme_en":71,"readme_zh":72,"quickstart_zh":73,"use_case_zh":74,"hero_image_url":75,"owner_login":76,"owner_name":77,"owner_avatar_url":78,"owner_bio":79,"owner_company":80,"owner_location":81,"owner_email":82,"owner_twitter":83,"owner_website":84,"owner_url":85,"languages":86,"stars":91,"forks":92,"last_commit_at":93,"license":94,"difficulty_score":23,"env_os":95,"env_gpu":96,"env_ram":96,"env_deps":97,"category_tags":103,"github_topics":104,"view_count":23,"oss_zip_url":115,"oss_zip_packed_at":115,"status":16,"created_at":116,"updated_at":117,"faqs":118,"releases":147},3611,"dougbrion\u002Fpytorch-classification-uncertainty","pytorch-classification-uncertainty","This repo contains a PyTorch implementation of the paper: \"Evidential Deep Learning to Quantify Classification Uncertainty\"","pytorch-classification-uncertainty 是一个基于 PyTorch 框架的开源项目，旨在复现并演示论文《Evidential Deep Learning to Quantify Classification Uncertainty》中的核心算法。传统深度学习模型往往只关注预测结果的准确性，却难以判断自己“有多大把握”做出该预测，导致在面对分布外数据或对抗攻击时，仍可能输出虚假的高置信度结果，存在安全隐患。\n\n该项目通过引入主观逻辑理论，将神经网络的预测视为一种“主观意见”，并利用狄利克雷分布对类别概率进行显式建模。这种方法让模型不仅能输出分类结果，还能量化预测的不确定性（即置信度），从而有效识别出那些模型未曾见过或经过恶意篡改的输入样本。相比传统的贝叶斯神经网络，该方法无需复杂的权重采样，计算效率更高且易于实现。\n\n此工具特别适合人工智能研究人员、算法工程师以及对模型安全性有较高要求的开发者使用。无论是希望深入研究不确定性量化机制的学者，还是需要在医疗诊断、自动驾驶等高风险场景中部署可靠模型的工程团队，都能利用 pytorch-classification","pytorch-classification-uncertainty 是一个基于 PyTorch 框架的开源项目，旨在复现并演示论文《Evidential Deep Learning to Quantify Classification Uncertainty》中的核心算法。传统深度学习模型往往只关注预测结果的准确性，却难以判断自己“有多大把握”做出该预测，导致在面对分布外数据或对抗攻击时，仍可能输出虚假的高置信度结果，存在安全隐患。\n\n该项目通过引入主观逻辑理论，将神经网络的预测视为一种“主观意见”，并利用狄利克雷分布对类别概率进行显式建模。这种方法让模型不仅能输出分类结果，还能量化预测的不确定性（即置信度），从而有效识别出那些模型未曾见过或经过恶意篡改的输入样本。相比传统的贝叶斯神经网络，该方法无需复杂的权重采样，计算效率更高且易于实现。\n\n此工具特别适合人工智能研究人员、算法工程师以及对模型安全性有较高要求的开发者使用。无论是希望深入研究不确定性量化机制的学者，还是需要在医疗诊断、自动驾驶等高风险场景中部署可靠模型的工程团队，都能利用 pytorch-classification-uncertainty 快速搭建原型，验证模型在异常情况下的鲁棒性，提升系统的整体可靠性。","# Evidential Deep Learning to Quantify Classification Uncertainty\n\n[![arXiv](http:\u002F\u002Fimg.shields.io\u002Fbadge\u002FarXiv-1806.01768-B31B1B.svg)](https:\u002F\u002Farxiv.org\u002Fabs\u002F1806.01768)\n\nThe purpose of this repository is to provide an easy-to-run demo using PyTorch with low computational requirements for the ideas proposed in the paper *Evidential Deep Learning to Quantify Classification Uncertainty*. The authors of the paper originally used Tensorflow in their implementation.\n\nThe paper can be accessed over at: [http:\u002F\u002Farxiv.org\u002Fabs\u002F1806.01768](http:\u002F\u002Farxiv.org\u002Fabs\u002F1806.01768)\n\nPart of: [Advances in Neural Information Processing Systems 31 (NIPS 2018)](https:\u002F\u002Fpapers.nips.cc\u002Fbook\u002Fadvances-in-neural-information-processing-systems-31-2018)\n\n## 📝 Table of Contents\n- [About](#about)\n- [Paper Abstract](#abstract)\n- [Authors](#authors)\n- [Demonstration](#demonstration)\n- [Usage](#usage)\n- [License](.\u002FLICENSE)\n- [Requirements](.\u002Frequirements.txt)\n\n## 🧐 About \u003Ca name = \"about\">\u003C\u002Fa>\nThe purpose of this repository is to provide an easy-to-run demo using PyTorch with low computational requirements for the ideas proposed in the paper *Evidential Deep Learning to Quantify Classification Uncertainty*. The authors of the paper originally used Tensorflow in their implementation.\n\nThe paper can be accessed over at: [http:\u002F\u002Farxiv.org\u002Fabs\u002F1806.01768](http:\u002F\u002Farxiv.org\u002Fabs\u002F1806.01768)\n\nPart of: [Advances in Neural Information Processing Systems 31 (NIPS 2018)](https:\u002F\u002Fpapers.nips.cc\u002Fbook\u002Fadvances-in-neural-information-processing-systems-31-2018)\n\n## 📚 Paper Abstract \u003Ca name = \"abstract\">\u003C\u002Fa>\n\nDeterministic neural nets have been shown to learn effective predictors on a wide range of machine learning problems. However, as the standard approach is to train the network to minimize a prediction loss, the resultant model remains ignorant to its prediction confidence. Orthogonally to Bayesian neural nets that indirectly infer prediction uncertainty through weight uncertainties, we propose explicit modeling of the same using the theory of subjective logic. By placing a Dirichlet distribution on the class probabilities, we treat predictions of a neural net as subjective opinions and learn the function that collects the evidence leading to these opinions by a deterministic neural net from data. The resultant predictor for a multi-class classification problem is another Dirichlet distribution whose parameters are set by the continuous output of a neural net. We provide a preliminary analysis on how the peculiarities of our new loss function drive improved uncertainty estimation. We observe that our method achieves unprecedented success on detection of out-of-distribution queries and endurance against adversarial perturbations.\n\n## ✍️ Authors \u003Ca name = \"authors\">\u003C\u002Fa>\nOriginal Paper authors:\n- [Murat Sensoy](https:\u002F\u002Fpapers.nips.cc\u002Fauthor\u002Fmurat-sensoy-11083)\n- [Lance Kaplan](https:\u002F\u002Fpapers.nips.cc\u002Fauthor\u002Flance-kaplan-11084)\n- [Melih Kandemir](https:\u002F\u002Fpapers.nips.cc\u002Fauthor\u002Fmelih-kandemir-11085)\n\nCode for this repository:\n- [Douglas Brion](https:\u002F\u002Fgithub.com\u002Fdougbrion)\n\n## 🏁 Demonstration \u003Ca name = \"demonstration\">\u003C\u002Fa>\n\n### Classification with Softmax Cross Entropy Loss Neural Network\n\nThe current standard for deep neural networks is to use the softmax operator to convert the continuous activations of the output layer to class probabilities.\n\nThe following demonstrates how softmax based Deep Neural Networks fail when they encounter out-of-sample queries.\n\nThe test accuracy for the network after 50 epochs is around 98.9%. Now, we want to classify a rotating digit from MNIST dataset to see how this network does for the samples that are not from the training set distribution.\n\nFor small degrees of rotation, the image is correctly classified as a \"1\" with high probability values. However, when the image is rotated by a larger amount the classification probability computed using the softmax function is still high even though the samples have been misclassified.\n\n\u003Cdiv align=\"center\">\n \n![Standard Network without Uncertainty](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fdougbrion_pytorch-classification-uncertainty_readme_be72830980b4.jpg)\n \n\u003Cb>Standard Network without Uncertainty\u003C\u002Fb>\n\u003C\u002Fdiv>\n\nAs shown above, a neural network trained to generate softmax probabilities fails significantly when it encounters a sample that is different from the training examples. The softmax forces neural network to pick one class, even though the object belongs to an unknown category. This is demonstrated when we rotate the digit one between 60 and 130 degrees. The network classifies the digit incorrectly as either a 5 or 7 while in this range, and with a high classification probability.\n\n### Classification with uncertainty using Expected Mean Square Error\n\nIdeally, we want a network to be \"unsure\" while trying to classify these objects that belong to an unkown category. Making the network say, *I do not know*, can be achieved by assigning all belief masses to the whole frame.\n\nAs described in the paper, a neural network can be trained to learn parameters of a Dirichlet distribution, instead of softmax probabilities. Dirichlet distributions with parameters  `α ≥ 1` behaves like a generative model for softmax probabilities (categorical distributions). It associates a likelihood value with each categorical distribution.\n\n\u003Cdiv align=\"center\">\n  \n  ![Expected Mean Square Error](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fdougbrion_pytorch-classification-uncertainty_readme_bbc34f7368a3.jpg)\n  \n  \u003Cb>Expected Mean Square Error\u003C\u002Fb>\n\u003C\u002Fdiv>\n\nThe figure above indicates that the proposed approach generates much smaller amount of evidence for the misclassified samples than the correctly classified ones. The uncertainty of the misclassified samples is high, around 1.0, while it is around 0.2 for the correctly classified ones, both for training and testing sets. This means that the neural network is very uncertain for the misclassified samples and provides certain predictions only for the correctly classified ones. In other words, the neural network also predicts when it fails by assigning high uncertainty to its wrong predictions.\n\nThe network above is trained using Eq. 5 in the paper. This loss function \n\n### Classification with uncertainty using Expected Cross Entropy\n\nIn this section, we train neural network using the loss function described in Eq. 4 in the paper. This loss function is derived using the expected value of the cross entropy loss over the predicted Dirichlet distribution.\n\n\u003Cdiv align=\"center\">\n \n  ![Expected Cross Entropy](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fdougbrion_pytorch-classification-uncertainty_readme_2052230c07e6.jpg)\n  \n  \u003Cb>Expected Cross Entropy\u003C\u002Fb>\n\u003C\u002Fdiv>\n\n\nThe figure above indicates that the neural network generates much more evidence for the correctly classified samples. As a result, it has a very low uncertainty (around zero) for the correctly classified samples, while the uncertainty is very high (around 0.7) for the misclassified samples.\n\n### Classification with uncertainty using Negative Log of the Expected Likelihood\n\nIn this section, we repeat our experiments using the loss function based on Eq. 3 in the paper.\n\n\u003Cdiv align=\"center\">\n\n![Negative Log of the Expected Likelihood](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fdougbrion_pytorch-classification-uncertainty_readme_0f1c61961ecb.jpg)\n\n\u003Cb>Negative Log of the Expected Likelihood\u003C\u002Fb>\n\u003C\u002Fdiv>\n\n## Comparing in sample and out of sample classification\n\nHere you can see how the network responds to a completely random image, in this case of Master Yoda... The network has an uncertainty of 1.0 and has given equal probability to all classes. Comparing this to the \"One\" digit, we can see that the uncertainty for the in sample image is much lower at around 0.15 and that here is a high confidence of it being a one with a classification probability of approximately 0.86.\n\n\nMNIST One Digit             |  Random Image of Yoda\n:-------------------------:|:-------------------------:\n![](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fdougbrion_pytorch-classification-uncertainty_readme_28a4a53e1a07.jpg)  |  ![](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fdougbrion_pytorch-classification-uncertainty_readme_eaa7f70c5499.jpg)\n\n\n## 🎈 Usage \u003Ca name = \"usage\">\u003C\u002Fa>\n\nAfter cloning this repo you need to install the requirements:\nThis has been tested with Python `v3.6.8`, Torch `v1.3.1` and Torchvision `v0.4.2`.\n\n```shell\npip install -r requirements.txt\n```\n\nThe are various arguments available for training and testing the network in addition to showing example data. When training or testing with uncertainty provide the `--uncertainty` argument in addition to one of the following for loss: `--mse`, `--digamma`, `--log`.\n\n```\npython main.py --help\n\nusage: main.py [-h] [--train] [--epochs EPOCHS] [--dropout] [--uncertainty]\n               [--mse] [--digamma] [--log] [--test] [--examples]\n\noptional arguments:\n  -h, --help       show this help message and exit\n  --train          To train the network.\n  --epochs EPOCHS  Desired number of epochs.\n  --dropout        Whether to use dropout or not.\n  --uncertainty    Use uncertainty or not.\n  --mse            Set this argument when using uncertainty. Sets loss\n                   function to Expected Mean Square Error.\n  --digamma        Set this argument when using uncertainty. Sets loss\n                   function to Expected Cross Entropy.\n  --log            Set this argument when using uncertainty. Sets loss\n                   function to Negative Log of the Expected Likelihood.\n  --test           To test the network.\n  --examples       To example MNIST data.\n```\n\nExample of how to train the network:\n\n```shell\npython main.py --train --dropout --uncertainty --mse --epochs 50\n```\n\n\nExample of how to test the network:\n\n```shell\npython main.py --test --uncertainty --mse\n```\n\n\n\n\n","# 证据深度学习用于量化分类不确定性\n\n[![arXiv](http:\u002F\u002Fimg.shields.io\u002Fbadge\u002FarXiv-1806.01768-B31B1B.svg)](https:\u002F\u002Farxiv.org\u002Fabs\u002F1806.01768)\n\n本仓库的目的是提供一个易于运行的PyTorch演示，该演示对计算资源要求较低，旨在实现论文《证据深度学习用于量化分类不确定性》中提出的思想。论文作者最初在其实现中使用了TensorFlow。\n\n论文可通过以下链接访问：[http:\u002F\u002Farxiv.org\u002Fabs\u002F1806.01768](http:\u002F\u002Farxiv.org\u002Fabs\u002F1806.01768)\n\n出自：[神经信息处理系统进展第31卷（NIPS 2018）](https:\u002F\u002Fpapers.nips.cc\u002Fbook\u002Fadvances-in-neural-information-processing-systems-31-2018)\n\n## 📝 目录\n- [简介](#about)\n- [论文摘要](#abstract)\n- [作者](#authors)\n- [演示](#demonstration)\n- [使用方法](#usage)\n- [许可证](.\u002FLICENSE)\n- [依赖项](.\u002Frequirements.txt)\n\n## 🧐 简介 \u003Ca name = \"about\">\u003C\u002Fa>\n本仓库的目的是提供一个易于运行的PyTorch演示，该演示对计算资源要求较低，旨在实现论文《证据深度学习用于量化分类不确定性》中提出的思想。论文作者最初在其实现中使用了TensorFlow。\n\n论文可通过以下链接访问：[http:\u002F\u002Farxiv.org\u002Fabs\u002F1806.01768](http:\u002F\u002Farxiv.org\u002Fabs\u002F1806.01768)\n\n出自：[神经信息处理系统进展第31卷（NIPS 2018）](https:\u002F\u002Fpapers.nips.cc\u002Fbook\u002Fadvances-in-neural-information-processing-systems-31-2018)\n\n## 📚 论文摘要 \u003Ca name = \"abstract\">\u003C\u002Fa>\n\n已有研究表明，确定性神经网络能够在广泛的机器学习问题上学习到有效的预测模型。然而，由于标准做法是训练网络以最小化预测损失，因此所得模型对其预测置信度一无所知。与通过权重不确定性间接推断预测不确定性的贝叶斯神经网络不同，我们提出利用主观逻辑理论对预测不确定性进行显式建模。通过在类别概率上施加狄利克雷分布，我们将神经网络的预测视为主观意见，并从数据中学习由确定性神经网络生成这些意见的证据收集函数。最终得到的多分类问题预测器是另一个狄利克雷分布，其参数由神经网络的连续输出决定。我们初步分析了新型损失函数的独特性质如何推动不确定性估计的改进。我们观察到，我们的方法在检测分布外样本以及抵御对抗性扰动方面取得了前所未有的成功。\n\n## ✍️ 作者 \u003Ca name = \"authors\">\u003C\u002Fa>\n原始论文作者：\n- [穆拉特·森索伊](https:\u002F\u002Fpapers.nips.cc\u002Fauthor\u002Fmurat-sensoy-11083)\n- [兰斯·卡普兰](https:\u002F\u002Fpapers.nips.cc\u002Fauthor\u002Flance-kaplan-11084)\n- [梅利赫·坎德米尔](https:\u002F\u002Fpapers.nips.cc\u002Fauthor\u002Fmelih-kandemir-11085)\n\n本仓库代码作者：\n- [道格拉斯·布里昂](https:\u002F\u002Fgithub.com\u002Fdougbrion)\n\n## 🏁 演示 \u003Ca name = \"demonstration\">\u003C\u002Fa>\n\n### 使用Softmax交叉熵损失的神经网络分类\n\n当前深度神经网络的标准做法是使用Softmax函数将输出层的连续激活值转换为类别概率。\n\n以下演示了基于Softmax的深度神经网络在遇到测试集之外的样本时的表现。\n\n经过50个epoch训练后，该网络的测试准确率约为98.9%。现在，我们希望对MNIST数据集中旋转后的数字进行分类，以观察该网络对于非训练集分布样本的表现如何。\n\n对于较小角度的旋转，图像会被正确地分类为“1”，且具有较高的概率值。然而，当图像被旋转到较大角度时，尽管样本已被错误分类，但使用Softmax函数计算出的分类概率仍然很高。\n\n\u003Cdiv align=\"center\">\n \n![无不确定性标准网络](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fdougbrion_pytorch-classification-uncertainty_readme_be72830980b4.jpg)\n \n\u003Cb>无不确定性标准网络\u003C\u002Fb>\n\u003C\u002Fdiv>\n\n如上所示，一个被训练为生成Softmax概率的神经网络，在遇到与训练样本不同的新样本时表现不佳。Softmax会强制神经网络选择一个类别，即使该对象属于未知类别。这一点在我们将数字旋转至60到130度之间时尤为明显。在此范围内，网络会错误地将数字分类为5或7，且分类概率还很高。\n\n### 使用期望均方误差进行不确定性分类\n\n理想情况下，我们希望网络在尝试分类属于未知类别对象时表现出“不确定”。让网络说“我不知道”可以通过将所有置信质量分配给整个框架来实现。\n正如论文所述，神经网络可以被训练为学习狄利克雷分布的参数，而不是Softmax概率。参数满足 `α ≥ 1` 的狄利克雷分布类似于Softmax概率（多项分布）的生成模型，它为每个多项分布关联一个似然值。\n\n\u003Cdiv align=\"center\">\n  \n  ![期望均方误差](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fdougbrion_pytorch-classification-uncertainty_readme_bbc34f7368a3.jpg)\n  \n  \u003Cb>期望均方误差\u003C\u002Fb>\n\u003C\u002Fdiv>\n\n上图表明，所提出的方案为错误分类的样本产生的证据远少于正确分类的样本。错误分类样本的不确定性较高，约为1.0，而正确分类样本的不确定性则较低，约为0.2，无论是在训练集还是测试集上均如此。这意味着神经网络对错误分类的样本非常不确定，而仅对正确分类的样本给出确定性的预测。换句话说，神经网络也能通过为其错误预测赋予高不确定性来判断自己是否失败。\n\n上述网络使用论文中的公式5进行训练。该损失函数…\n\n### 使用期望交叉熵进行不确定性分类\n\n在这一部分，我们使用论文中公式4描述的损失函数来训练神经网络。该损失函数是通过对预测的狄利克雷分布计算交叉熵损失的期望值得到的。\n\n\u003Cdiv align=\"center\">\n \n  ![期望交叉熵](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fdougbrion_pytorch-classification-uncertainty_readme_2052230c07e6.jpg)\n  \n  \u003Cb>期望交叉熵\u003C\u002Fb>\n\u003C\u002Fdiv>\n\n\n上图表明，神经网络为正确分类的样本产生了更多的证据。因此，它对正确分类的样本表现出极低的不确定性（接近于零），而对错误分类的样本则表现出很高的不确定性（约为0.7）。\n\n### 使用期望似然的负对数进行不确定性分类\n\n在本节中，我们使用论文中公式3所定义的损失函数重复实验。\n\n\u003Cdiv align=\"center\">\n\n![期望似然的负对数](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fdougbrion_pytorch-classification-uncertainty_readme_0f1c61961ecb.jpg)\n\n\u003Cb>期望似然的负对数\u003C\u002Fb>\n\u003C\u002Fdiv>\n\n## 样本内与样本外分类的比较\n\n在这里可以看到网络对一张完全随机的图像（本例中为尤达大师）的响应。此时网络的不确定性为1.0，对所有类别赋予了相同的概率。将其与“1”这个数字进行对比，我们可以发现，对于样本内的图像，不确定性要低得多，约为0.15；同时，网络对该图像为“1”的置信度很高，分类概率大约为0.86。\n\n\nMNIST中的数字“1”             |  尤达大师的随机图像\n:-------------------------:|:-------------------------:\n![](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fdougbrion_pytorch-classification-uncertainty_readme_28a4a53e1a07.jpg)  |  ![](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fdougbrion_pytorch-classification-uncertainty_readme_eaa7f70c5499.jpg)\n\n\n## 🎈 使用方法 \u003Ca name = \"usage\">\u003C\u002Fa>\n\n克隆本仓库后，需要安装所需的依赖包：  \n此项目已在Python `v3.6.8`、Torch `v1.3.1`和Torchvision `v0.4.2`环境下测试通过。\n\n```shell\npip install -r requirements.txt\n```\n\n除了展示示例数据外，训练和测试网络时还提供了多种参数选项。当使用不确定性进行训练或测试时，需在指定损失函数的同时添加`--uncertainty`参数，可选的损失函数包括：`--mse`、`--digamma`、`--log`。\n\n```\npython main.py --help\n\n用法：main.py [-h] [--train] [--epochs EPOCHS] [--dropout] [--uncertainty]\n               [--mse] [--digamma] [--log] [--test] [--examples]\n\n可选参数：\n  -h, --help       显示帮助信息并退出\n  --train          训练网络。\n  --epochs EPOCHS  指定训练的轮数。\n  --dropout        是否使用Dropout。\n  --uncertainty    是否启用不确定性。\n  --mse            使用不确定性时设置该参数，将损失函数设为期望均方误差。\n  --digamma        使用不确定性时设置该参数，将损失函数设为期望交叉熵。\n  --log            使用不确定性时设置该参数，将损失函数设为期望似然的负对数。\n  --test           测试网络。\n  --examples       展示MNIST示例数据。\n```\n\n训练网络的示例：\n\n```shell\npython main.py --train --dropout --uncertainty --mse --epochs 50\n```\n\n\n测试网络的示例：\n\n```shell\npython main.py --test --uncertainty --mse\n```","# pytorch-classification-uncertainty 快速上手指南\n\n本工具基于论文《Evidential Deep Learning to Quantify Classification Uncertainty》（NIPS 2018），使用 PyTorch 复现了通过证据深度学习量化分类不确定性的方法。相比传统 Softmax 模型，该模型能有效识别分布外样本（Out-of-Distribution）并抵抗对抗攻击。\n\n## 环境准备\n\n本项目已在以下环境中测试通过，建议参考此配置：\n- **Python**: v3.6.8+\n- **PyTorch**: v1.3.1+\n- **Torchvision**: v0.4.2+\n\n确保系统已安装 Python 和 pip。国内用户建议在安装依赖时指定清华或阿里镜像源以加速下载。\n\n## 安装步骤\n\n1. **克隆仓库**\n   ```bash\n   git clone https:\u002F\u002Fgithub.com\u002Fdougbrion\u002Fpytorch-classification-uncertainty.git\n   cd pytorch-classification-uncertainty\n   ```\n\n2. **安装依赖**\n   推荐使用国内镜像源安装 `requirements.txt` 中的依赖包：\n   ```bash\n   pip install -r requirements.txt -i https:\u002F\u002Fpypi.tuna.tsinghua.edu.cn\u002Fsimple\n   ```\n\n## 基本使用\n\n该工具支持多种损失函数进行不确定性建模（MSE、Digamma、Log）。以下是训练和测试的最简示例。\n\n### 1. 训练模型\n使用 **Expected Mean Square Error (MSE)** 损失函数训练网络，开启不确定性模式并启用 Dropout，训练 50 个 epoch：\n\n```bash\npython main.py --train --dropout --uncertainty --mse --epochs 50\n```\n\n> **参数说明**：\n> - `--uncertainty`: 启用不确定性量化模式。\n> - `--mse`: 设置损失函数为期望均方误差（也可替换为 `--digamma` 或 `--log`）。\n> - `--dropout`: 启用 Dropout 正则化。\n\n### 2. 测试模型\n使用训练好的模型进行测试，评估其对未知样本的不确定性判断能力：\n\n```bash\npython main.py --test --uncertainty --mse\n```\n\n### 3. 查看示例数据\n运行以下命令查看 MNIST 数据集在旋转角度变化下的分类置信度与不确定性对比演示：\n\n```bash\npython main.py --examples\n```","某医疗影像初创团队正在开发基于深度学习的肺部结节分类系统，旨在辅助医生判断 CT 扫描图像中结节的良恶性。\n\n### 没有 pytorch-classification-uncertainty 时\n- **盲目自信导致误诊风险**：模型面对从未见过的模糊病灶或噪声干扰图像（分布外数据）时，仍会输出极高的置信度（如 99%），误导医生做出错误判断。\n- **缺乏对抗攻击防御力**：当输入图像遭受微小的恶意扰动时，传统 Softmax 模型极易发生预测翻转，且无法感知自身判断已不可靠。\n- **难以界定决策边界**：开发人员无法区分模型是“真的确定”还是“瞎猜”，导致在高风险场景下不敢部署，必须依赖大量人工复核。\n\n### 使用 pytorch-classification-uncertainty 后\n- **精准量化未知风险**：通过证据深度学习将预测建模为狄利克雷分布，模型遇到模糊或异常图像时能主动输出高不确定性值，提示医生“此图存疑，需人工介入”。\n- **增强鲁棒性与安全性**：在面对对抗性扰动时，模型能敏锐捕捉到证据不足，显著降低错误分类的置信度，有效拦截潜在的攻击样本。\n- **实现智能分流机制**：团队可依据不确定性阈值建立自动过滤流程，仅将低置信度的复杂案例转交专家，大幅提升了整体诊疗流程的效率与安全性。\n\npytorch-classification-uncertainty 的核心价值在于让 AI 从“盲目猜测”进化为“知之为知之，不知为不知”，为高风险领域的落地应用提供了关键的安全阀。","https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fdougbrion_pytorch-classification-uncertainty_be728309.jpg","dougbrion","Douglas Brion","https:\u002F\u002Foss.gittoolsai.com\u002Favatars\u002Fdougbrion_a8243fa8.jpg","Founder & CEO of Matta","Matta AI + University of Cambridge","London, UK","me@douglasbrion.com","douglas_brion","http:\u002F\u002Fdouglasbrion.com","https:\u002F\u002Fgithub.com\u002Fdougbrion",[87],{"name":88,"color":89,"percentage":90},"Python","#3572A5",100,517,71,"2026-03-26T09:31:42","MIT","","未说明",{"notes":98,"python":99,"dependencies":100},"该项目旨在提供低计算需求的演示。代码已在 Python 3.6.8、PyTorch 1.3.1 和 Torchvision 0.4.2 环境下测试通过。训练时可通过参数选择三种不同的不确定性损失函数（--mse, --digamma, --log）。","3.6.8",[101,102],"torch==1.3.1","torchvision==0.4.2",[13],[105,106,107,108,109,110,111,112,113,114],"paper","pytorch","evidential-deep-learning","uncertainty-neural-networks","classification","mnist","mnist-classification","dirichlet-distributions","uncertainty","torchvision",null,"2026-03-27T02:49:30.150509","2026-04-06T07:12:44.320778",[119,124,129,133,138,143],{"id":120,"question_zh":121,"answer_zh":122,"source_url":123},16549,"代码中的 KL 散度（KL Divergence）实现与论文公式不一致，多出的 `torch.lgamma(ones)` 项有什么作用？","这是为了将论文公式中的对数项拆解以便于代码实现。虽然 `torch.lgamma(ones)`（即 log-gamma 全 1 向量）的计算结果恒为 0，在数值上不影响结果，但保留该项是为了保持公式结构的完整性和清晰度。维护者确认代码逻辑与论文一致，差异仅源于随机训练方差或未设置随机种子。","https:\u002F\u002Fgithub.com\u002Fdougbrion\u002Fpytorch-classification-uncertainty\u002Fissues\u002F3",{"id":125,"question_zh":126,"answer_zh":127,"source_url":128},16550,"如何正确计算不确定性（Uncertainty, u）？它与分类概率（p_k）和信念质量（b_k）有什么关系？","不确定性 `u` 不等于 `1 - 分类概率`。根据证据深度学习（EDL）论文：\n1. 信念质量 `b_k = e_k \u002F S = (alpha_k - 1) \u002F S`。\n2. 分类概率 `p_k = alpha_k \u002F S`。\n3. 不确定性 `u = 1 - sum_k(b_k)`。\n例如，当所有类别的证据 `e_k = 0` 时，`alpha_k = 1`，此时 `b_k = 0`，因此 `u = 1`（完全不确定），而分类概率 `p_k = 1\u002FK`（均匀分布）。","https:\u002F\u002Fgithub.com\u002Fdougbrion\u002Fpytorch-classification-uncertainty\u002Fissues\u002F2",{"id":130,"question_zh":131,"answer_zh":132,"source_url":128},16551,"为什么在“大师尤达”（Master Yoda）的例子中，即使其他类别的分类概率看起来不为 0，不确定性却是 1.0？","这是因为在该样本中，模型对所有 K 个类别的证据（evidence）`e_k` 均为 0。根据公式，这导致 `alpha_k = 1`，进而使得信念质量 `b_k = 0`。由于不确定性 `u = 1 - sum(b_k)`，所以 `u = 1`。此时分类概率 `p_k = alpha_k \u002F S = 1\u002FK`，表现为均匀分布，代表模型对该样本完全无知，因此不确定性最大。",{"id":134,"question_zh":135,"answer_zh":136,"source_url":137},16552,"如何将此方法应用于具有不同类别数量（num_classes）的数据集？","训练代码中存在一个小 bug，硬编码了类别数量。需要修改 `train.py` 第 55 行附近的代码，将固定的类别数替换为动态变量。具体修改如下：\n原代码可能类似：`y = one_hot_embedding(labels, 10)` （假设硬编码为 10）\n修改为：`y = one_hot_embedding(labels, num_classes)`\n确保 `num_classes` 是你当前数据集的实际类别数量。","https:\u002F\u002Fgithub.com\u002Fdougbrion\u002Fpytorch-classification-uncertainty\u002Fissues\u002F1",{"id":139,"question_zh":140,"answer_zh":141,"source_url":142},16553,"KL 散度函数中 `first_term` 里的 `+ torch.lgamma(ones).sum(...)` 是否是无意义的代码？","从数值计算角度看，`log-gamma([1, 1, ...])` 确实恒等于 0，该项相加不改变结果。但这并非无意义代码，而是为了严格对应论文公式中 Dirichlet 分布归一化常数的展开形式。保留它可以使代码结构与数学推导过程保持一致，方便对照阅读，实际运行中会被优化或视为零值处理。","https:\u002F\u002Fgithub.com\u002Fdougbrion\u002Fpytorch-classification-uncertainty\u002Fissues\u002F7",{"id":144,"question_zh":145,"answer_zh":146,"source_url":128},16554,"在使用 MobileNetV2 等模型时，发现准确率很高但不确定性指标表现不佳，可能的原因是什么？","理论上概率与不确定性应呈反比关系（`u + sum(b_k) ≈ 1`）。如果出现准确率高但不确定性低（或不符合预期）的情况，可能是因为：\n1. 模型在训练集上过拟合，导致对未知数据缺乏真正的“证据”积累。\n2. 可视化时混淆了 `max(p_k)` 与 `u` 的关系，实际上 `u` 与最大概率没有直接的线性公式关系，而是取决于所有类别的信念质量之和。\n建议检查验证集上的 `alpha` 参数分布，确保证据值在非目标类别上未被错误地推高。",[]]