[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"similar-google-research--morph-net":3,"tool-google-research--morph-net":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 真正成长为懂上",140436,2,"2026-04-05T23:32:43",[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":69,"readme_en":70,"readme_zh":71,"quickstart_zh":72,"use_case_zh":73,"hero_image_url":74,"owner_login":75,"owner_name":76,"owner_avatar_url":77,"owner_bio":78,"owner_company":79,"owner_location":79,"owner_email":79,"owner_twitter":79,"owner_website":80,"owner_url":81,"languages":82,"stars":91,"forks":92,"last_commit_at":93,"license":94,"difficulty_score":95,"env_os":96,"env_gpu":97,"env_ram":96,"env_deps":98,"category_tags":103,"github_topics":104,"view_count":23,"oss_zip_url":79,"oss_zip_packed_at":79,"status":16,"created_at":110,"updated_at":111,"faqs":112,"releases":145},3353,"google-research\u002Fmorph-net","morph-net","Fast & Simple Resource-Constrained Learning of Deep Network Structure","MorphNet 是一款专为深度学习模型设计的结构优化工具，旨在训练过程中自动学习并调整网络架构，以满足特定的资源限制。它主要解决了在内存、计算量（FLOPs）或延迟受限的设备上部署大型神经网络时的难题，帮助开发者在不手动重新设计拓扑的前提下，高效地压缩模型体积并提升推理速度。\n\n该工具非常适合从事移动端部署、边缘计算的研究人员及工程师使用。其核心原理是通过引入特殊的正则化项，在训练时动态抑制不重要滤波器的影响力，从而自动识别并剪枝冗余的输出通道。值得一提的是，MorphNet 最新集成了名为 FiGS（细粒度随机架构搜索）的概率化方法，通过逻辑门控机制实现更精准的通道正则化。这种方法不仅优于传统的剪枝算法，还能作为可微分架构搜索方案，让用户仅需设定目标成本（如延迟或模型大小），即可从现有“种子网络”中衍生出符合约束的高效新模型，整个过程快速且易于集成。","# MorphNet: Fast & Simple Resource-Constrained Learning of Deep Network Structure\n\n[TOC]\n\n## New: FiGS: Fine-Grained Stochastic Architecture Search\nFiGS, is a probabilistic approach to channel regularization that we introduced\nin [Fine-Grained Stochastic Architecture Search](https:\u002F\u002Farxiv.org\u002Fpdf\u002F2006.09581.pdf).\nIt outperforms our previous regularizers and can be used as either a pruning algorithm or\na full fledged Differentiable Architecture Search method. This is the recommended\nway to apply MorphNet. In the below documentation it is\nreferred to as the `LogisticSigmoid` regularizer.\n\n\n## What is MorphNet?\nMorphNet is a method for learning deep network structure during training. The\nkey principle is continuous relaxation of the network-structure learning\nproblem. In short, the MorphNet regularizer pushes the influence of filters down,\nand once they are small enough, the corresponding output channels are marked\nfor removal from the network.\n\n\nSpecifically, activation sparsity is induced by adding regularizers\nthat target the consumption of specific resources such as FLOPs or model size.\nWhen the regularizer loss is added to the training loss and their sum is\nminimized via stochastic gradient descent or a similar optimizer, the learning\nproblem becomes a constrained optimization of the structure of the network,\nunder the constraint represented by the regularizer. The method was first\nintroduced in our [CVPR 2018](http:\u002F\u002Fcvpr2018.thecvf.com\u002F), paper \"[MorphNet: Fast & Simple Resource-Constrained Learning of\nDeep Network Structure](https:\u002F\u002Farxiv.org\u002Fabs\u002F1711.06798)\". A overview of the\napproach as well as device-specific latency regularizers were prestend in\n[GTC 2019](https:\u002F\u002Fgputechconf2019.smarteventscloud.com\u002Fconnect\u002FsessionDetail.ww?SESSION_ID=272314).  [[slides](g3doc\u002F\u002FMorphNet_GTC2019.pdf \"GTC Slides\"), recording: [YouTube](https:\u002F\u002Fyoutu.be\u002FUvTXhTvJ_wM), [GTC on-demand](https:\u002F\u002Fon-demand.gputechconf.com\u002Fgtc\u002F2019\u002Fvideo\u002F_\u002FS9645\u002F)].\nOur new, probabilistic, approach to pruning is called FiGS, and is detailed in\n[Fine-Grained Stochastic Architecture Search](https:\u002F\u002Farxiv.org\u002Fpdf\u002F2006.09581.pdf).\n\n\n## Usage\n\nSuppose you have a working convolutional neural network for image classification\nbut want to shrink the model to satisfy some constraints (e.g., memory,\nlatency). Given an existing model (the “seed network”) and a target criterion,\nMorphNet will propose a new model by adjusting the number of output channels in\neach convolution layer.\n\nNote that MorphNet does not change the topology of the network -- the proposed\nmodel will have the same number of layers and connectivity pattern as the seed\nnetwork.\n\nTo use MorphNet, you must:\n\n1.  Choose a regularizer from `morphnet.network_regularizers`. The choice is\n    based on\n\n    *   your target cost (e.g., FLOPs, latency)\n    *   Your ability to add new layers to your model:\n        * Add\n          our probabilistic gating operation after any layer you wish to prune, and\n          use the `LogisticSigmoid` regularizers. **\\[recommended\\]**\n        * If you are unable to add new layers, select regularizer type based on\n          your network architecture: use `Gamma` regularizer if the seed network\n          has BatchNorm; use `GroupLasso` otherwise \\[deprecated\\].\n\n    Note: If you use BatchNorm, you must enable the scale parameters (“gamma\n    variables”), i.e., by setting `scale=True` if you are using\n    `tf.keras.layers.BatchNormalization`.\n\n    Note: If you are using `LogisticSigmoid` don't forget to add the\n    probabilistic gating op! See below for example.\n\n2.  Initialize the regularizer with a threshold and the output boundary ops and\n    (optionally) the input boundary ops of your model.\n\n    MorphNet regularizer crawls your graph starting from the output boundary,\n    and applies regularization to some of the ops it encounters. When it\n    encounters any of the input boundary ops, it does not crawl past them (the\n    ops in the input boundary are not regularized). The threshold determines\n    which output channels can be eliminated.\n\n3.  Add the regularization term to your loss.\n\n    As always, regularization loss must be scaled. We recommend to search for\n    the scaling hyperparameter (*regularization strength*) along a logarithmic\n    scale spanning a few orders of magnitude around `1\u002F(initial cost)`. For\n    example, if the seed network starts with 1e9 FLOPs, explore regularization\n    strength around 1e-9.\n\n    Note: MorphNet does not currently add the regularization loss to the\n    tf.GraphKeys.REGULARIZATION_LOSSES collection; this choice is subject to\n    revision.\n\n    Note: Do not confuse `get_regularization_term()` (the loss you should add to\n    your training) with `get_cost()` (the estimated cost of the network if the\n    proposed structure is applied).\n\n4.  Train the model.\n\n    Note: We recommend using a fixed learning rate (no decay) for this step,\n    though this is not strictly necessary.\n\n5.  Save the proposed model structure with the `StructureExporter`.\n\n    The exported files are in JSON format. Note that as the training progresses,\n    the proposed model structure will change. There are no specific guidelines\n    on the stopping time, although you would likely want to wait for the\n    regularization loss (reported via summaries) to stabilize.\n\n6.  (Optional) Create summary ops to monitor the training progress through\n    TensorBoard.\n\n7.  Modify your model using the `StructureExporter` output.\n\n8.  Retrain the model from scratch without the MorphNet regularizer.\n\n    Note: Use the standard values for all hyperparameters (such as the learning\n    rate schedule).\n\n9.  (Optional) Uniformly expand the network to adjust the accuracy vs. cost\n    trade-off as desired. Alternatively, this step can be performed *before*\n    the structure learning step.\n\nWe refer to the first round of training as *structure learning* and the second\nround as *retraining*.\n\nTo summarize, the key hyperparameters for MorphNet are:\n\n*   Regularization strength\n*   Alive threshold\n\nNote that the regularizer type is not a hyperparameter because it's uniquely\ndetermined by the metric of interest (FLOPs, latency) and the presence of\nBatchNorm.\n\n## Regularizer Types\n\nRegularizer classes can be found under `network_regularizers\u002F` directory. They\nare named by the algorithm they use and the target cost they attempt to\nminimize. For example, `LogisticSigmoidFlopsRegularizer` uses a\nLogistic-Sigmoid probabilistic method to to regularize the FLOP cost\nand `GammaModelSizeRegularizer` uses the batch norm gamma in\norder to regularize the model size cost.\n\n### Regularizer Algorithms\n\n* **[NEW] LogisticSigmoid** is designed to control any model type, but requires\n  adding simple `gating layers` to your model.\n* **GroupLasso** is designed for models without batch norm.\n* **Gamma** is designed for models with batch norm; it requires that batch\n   norm scale is enabled.\n\n### Regularizer Target Costs\n\n* *Flops* targets the FLOP count of the inference network.\n* *Model Size* targets the number of weights of the network.\n* *Latency* optimizes for the estimated inference latency of the network, based\non the specific hardware characteristics.\n\n## Examples\n\n### Adding a FLOPs Regularizer\n\nThe example below demonstrates how to use MorphNet to reduce the number of FLOPs\nin your model. In this example, the regularizer will traverse the graph\nstarting with `logits`, and will not go past any op that is earlier in the graph\nthan the `inputs` or `labels`; this allows to specify the subgraph for MorphNet to optimize.\n\n\u003C!-- TODO Add Keras example. -->\n```python\nfrom morph_net.network_regularizers import flop_regularizer\nfrom morph_net.tools import structure_exporter\n\ndef build_model(inputs, labels, is_training, ...):\n  gated_relu = activation_gating.gated_relu_activation()\n\n  net = tf.layers.conv2d(inputs, kernel=[5, 5], num_outputs=256)\n  net = gated_relu(net, is_training=is_training)\n\n  ...\n  ...\n\n  net = tf.layers.conv2d(net, kernel=[3, 3], num_outputs=1024)\n  net = gated_relu(net, is_training=is_training)\n\n  logits = tf.reduce_mean(net, [1, 2])\n  logits = tf.layers.dense(logits, units=1024)\n  return logits\n\ninputs, labels = preprocessor()\nlogits = build_model(inputs, labels, is_training=True, ...)\n\nnetwork_regularizer = flop_regularizer.LogisticSigmoidFlopsRegularizer(\n    output_boundary=[logits.op],\n    input_boundary=[inputs.op, labels.op],\n    alive_threshold=0.1  # Value in [0, 1]. This default works well for most cases.\n)\nregularization_strength = 1e-10\nregularizer_loss = (network_regularizer.get_regularization_term() * regularization_strength)\n\nmodel_loss = tf.nn.sparse_softmax_cross_entropy_with_logits(labels, logits)\n\noptimizer = tf.train.MomentumOptimizer(learning_rate=0.01, momentum=0.9)\n\ntrain_op = optimizer.minimize(model_loss + regularizer_loss)\n```\n\nYou should monitor the progress of structure learning training via Tensorboard.\nIn particular, you should consider adding a summary that computes the current\nMorphNet regularization loss and the cost if the currently proposed structure is\nadopted.\n\n```python\ntf.summary.scalar('RegularizationLoss', regularizer_loss)\ntf.summary.scalar(network_regularizer.cost_name, network_regularizer.get_cost())\n```\n\n![TensorBoardDisplayOfFlops](g3doc\u002Ftensorboard.png \"Example of the TensorBoard display of the resource regularized by MorphNet.\")\n\nLarger values of `regularization_strength` will converge to smaller effective\nFLOP count. If `regularization_strength` is large enough, the FLOP count will\ncollapse to zero. Conversely, if it is small enough, the FLOP count will remain\nat its initial value and the network structure will not vary. The\n`regularization_strength` parameter is your knob to control where you want to be\non the price-performance curve. The `alive_threshold` parameter is used for\ndetermining when an activation is alive.\n\n### Extracting the Architecture Learned by MorphNet\n\nDuring training, you should save a JSON file that contains the learned structure\nof the network, that is the count of activations in a given layer kept alive (as\nopposed to removed) by MorphNet.\n\n```python\nexporter = structure_exporter.StructureExporter(\n    network_regularizer.op_regularizer_manager)\n\nwith tf.Session() as sess:\n  tf.global_variables_initializer().run()\n  for step in range(max_steps):\n    _, structure_exporter_tensors = sess.run([train_op, exporter.tensors])\n    if (step % 1000 == 0):\n      exporter.populate_tensor_values(structure_exporter_tensors)\n      exporter.create_file_and_save_alive_counts(train_dir, step)\n```\n\n## Misc\n\nContact: morphnet@google.com\n\n### Maintainers\n\n*   Elad Eban, github: [eladeban](https:\u002F\u002Fgithub.com\u002Feladeban)\n*   Andrew Poon, github: [ayp-google](https:\u002F\u002Fgithub.com\u002Fayp-google)\n*   Yair Movshovitz-Attias, github: [yairmov](https:\u002F\u002Fgithub.com\u002Fyairmov)\n*   Max Moroz, github: [pkch](https:\u002F\u002Fgithub.com\u002Fpkch)\n\n### Contributors\n\n*   Ariel Gordon, github: [gariel-google](https:\u002F\u002Fgithub.com\u002Fgariel-google).\n","# MorphNet：快速且简单的资源受限深度网络结构学习\n\n[目录]\n\n## 新功能：FiGS：细粒度随机架构搜索\nFiGS 是一种概率性的通道正则化方法，我们在《细粒度随机架构搜索》论文中首次提出（https:\u002F\u002Farxiv.org\u002Fpdf\u002F2006.09581.pdf）。它优于我们之前的正则化方法，既可以作为剪枝算法使用，也可以作为一种完整的可微架构搜索方法。这是推荐的 MorphNet 使用方式，在以下文档中被称为 `LogisticSigmoid` 正则化器。\n\n\n## 什么是 MorphNet？\nMorphNet 是一种在训练过程中学习深度网络结构的方法。其核心思想是将网络结构学习问题进行连续松弛。简而言之，MorphNet 正则化器会逐渐降低滤波器的影响，当这些影响足够小的时候，对应的输出通道就会被标记为可以从网络中移除。\n\n\n具体来说，通过添加针对特定资源消耗（如 FLOPs 或模型大小）的正则化项，可以诱导激活稀疏性。当正则化损失与训练损失相加，并通过随机梯度下降或其他类似优化器最小化时，学习问题就转化为一个受正则化项约束的网络结构优化问题。该方法最早在我们的 CVPR 2018 论文《MorphNet：快速且简单的资源受限深度网络结构学习》（https:\u002F\u002Farxiv.org\u002Fabs\u002F1711.06798）中提出。关于该方法的概述以及针对不同设备延迟的正则化器，则在 GTC 2019 上进行了展示[[幻灯片](g3doc\u002F\u002FMorphNet_GTC2019.pdf \"GTC 幻灯片\")]，录像可在 [YouTube](https:\u002F\u002Fyoutu.be\u002FUvTXhTvJ_wM) 和 [GTC 按需观看](https:\u002F\u002Fon-demand.gputechconf.com\u002Fgtc\u002F2019\u002Fvideo\u002F_\u002FS9645\u002F) 中找到。我们新的概率性剪枝方法称为 FiGS，详细内容见《细粒度随机架构搜索》（https:\u002F\u002Farxiv.org\u002Fpdf\u002F2006.09581.pdf）。\n\n\n## 使用方法\n\n假设你已经有一个用于图像分类的卷积神经网络，但希望缩小模型以满足某些约束条件（例如内存或延迟）。给定一个现有模型（“种子网络”）和一个目标指标，MorphNet 将通过调整每个卷积层的输出通道数来生成一个新的模型。\n\n需要注意的是，MorphNet 不会改变网络的拓扑结构——生成的模型将与种子网络具有相同的层数和连接模式。\n\n要使用 MorphNet，你需要：\n\n1.  从 `morphnet.network_regularizers` 中选择一个正则化器。选择依据包括：\n    *   你的目标成本（例如 FLOPs、延迟）\n    *   你是否能够在模型中添加新层：\n        * 在你希望剪枝的任何层之后添加我们的概率门控操作，并使用 `LogisticSigmoid` 正则化器。**[推荐]**\n        * 如果无法添加新层，则根据你的网络架构选择正则化器类型：如果种子网络包含 BatchNorm，则使用 `Gamma` 正则化器；否则使用 `GroupLasso` 正则化器\\[已弃用\\]。\n\n    注意：如果你使用 BatchNorm，必须启用缩放参数（“gamma 变量”），即在使用 `tf.keras.layers.BatchNormalization` 时设置 `scale=True`。\n\n    注意：如果你使用 `LogisticSigmoid`，别忘了添加概率门控操作！示例如下。\n\n2.  使用阈值以及模型的输出边界操作（可选地还包括输入边界操作）初始化正则化器。\n\n    MorphNet 正则化器会从输出边界开始遍历你的计算图，并对遇到的一些操作应用正则化。当它遇到任何输入边界操作时，就不会再继续向下遍历（输入边界内的操作不会被正则化）。阈值决定了哪些输出通道可以被移除。\n\n3.  将正则化项添加到你的损失函数中。\n\n    和往常一样，正则化损失需要进行缩放。我们建议在以 `1\u002F初始成本` 为中心的几个数量级范围内，沿对数尺度搜索缩放超参数（即正则化强度）。例如，如果种子网络的初始 FLOPs 数量为 1e9，则可以在 1e-9 左右探索正则化强度。\n\n    注意：目前 MorphNet 尚未将正则化损失添加到 `tf.GraphKeys.REGULARIZATION_LOSSES` 集合中；这一选择可能会被修订。\n\n    注意：不要混淆 `get_regularization_term()`（你应该添加到训练中的损失）和 `get_cost()`（如果应用提议的结构，网络的预计成本）。\n\n4.  训练模型。\n\n    注意：我们建议在此步骤中使用固定的学习率（不衰减），但这并非严格必要。\n\n5.  使用 `StructureExporter` 保存提议的模型结构。\n\n    导出的文件为 JSON 格式。需要注意的是，随着训练的进行，提议的模型结构会发生变化。虽然没有明确的停止时机指导，但通常建议等到通过摘要报告的正则化损失趋于稳定时再停止。\n\n6.  （可选）创建摘要操作，以便通过 TensorBoard 监控训练进度。\n\n7.  使用 `StructureExporter` 的输出修改你的模型。\n\n8.  从头开始重新训练模型，不再使用 MorphNet 正则化器。\n\n    注意：所有超参数（如学习率调度）都应使用标准值。\n\n9.  （可选）均匀扩展网络，以按需调整准确率与成本之间的权衡。或者，这一步也可以在结构学习之前完成。\n\n我们将第一轮训练称为“结构学习”，第二轮称为“重训”。\n\n总结一下，MorphNet 的关键超参数包括：\n\n*   正则化强度\n*   存活阈值\n\n需要注意的是，正则化器类型并不是超参数，因为它完全由你关注的指标（FLOPs、延迟）以及是否使用 BatchNorm 决定。\n\n\n## 正则化器类型\n\n正则化器类位于 `network_regularizers\u002F` 目录下。它们的命名基于所使用的算法以及试图最小化的目标成本。例如，`LogisticSigmoidFlopsRegularizer` 使用逻辑斯蒂- sigmoid 概率方法来正则化 FLOPs 成本，而 `GammaModelSizeRegularizer` 则利用批归一化中的 gamma 参数来正则化模型大小成本。\n\n### 正则化器算法\n\n* **[新] LogisticSigmoid** 适用于控制任何类型的模型，但需要在你的模型中添加简单的“门控层”。\n* **GroupLasso** 专为不含批归一化的模型设计。\n* **Gamma** 专为含有批归一化的模型设计；它要求批归一化的缩放参数必须启用。\n\n### 正则化器目标成本\n\n* *FLOPs* 以推理网络的 FLOP 计数为目标。\n* *模型大小* 以网络的权重数量为目标。\n* *延迟* 根据特定硬件特性，优化网络的估计推理延迟。\n\n## 示例\n\n### 添加 FLOPs 正则化器\n\n下面的示例展示了如何使用 MorphNet 来减少模型中的 FLOPs 数量。在本例中，正则化器将从 `logits` 开始遍历计算图，并且不会跨越任何在图中位于 `inputs` 或 `labels` 之前的算子；这允许指定 MorphNet 需要优化的子图。\n\n\u003C!-- TODO 添加 Keras 示例。 -->\n```python\nfrom morph_net.network_regularizers import flop_regularizer\nfrom morph_net.tools import structure_exporter\n\ndef build_model(inputs, labels, is_training, ...):\n  gated_relu = activation_gating.gated_relu_activation()\n\n  net = tf.layers.conv2d(inputs, kernel=[5, 5], num_outputs=256)\n  net = gated_relu(net, is_training=is_training)\n\n  ...\n  ...\n\n  net = tf.layers.conv2d(net, kernel=[3, 3], num_outputs=1024)\n  net = gated_relu(net, is_training=is_training)\n\n  logits = tf.reduce_mean(net, [1, 2])\n  logits = tf.layers.dense(logits, units=1024)\n  return logits\n\ninputs, labels = preprocessor()\nlogits = build_model(inputs, labels, is_training=True, ...)\n\nnetwork_regularizer = flop_regularizer.LogisticSigmoidFlopsRegularizer(\n    output_boundary=[logits.op],\n    input_boundary=[inputs.op, labels.op],\n    alive_threshold=0.1  # 值范围为 [0, 1]。此默认值在大多数情况下效果良好。\n)\nregularization_strength = 1e-10\nregularizer_loss = (network_regularizer.get_regularization_term() * regularization_strength)\n\nmodel_loss = tf.nn.sparse_softmax_cross_entropy_with_logits(labels, logits)\n\noptimizer = tf.train.MomentumOptimizer(learning_rate=0.01, momentum=0.9)\n\ntrain_op = optimizer.minimize(model_loss + regularizer_loss)\n```\n\n您应该通过 TensorBoard 监控结构学习训练的进展。特别是，您应考虑添加一个摘要，用于计算当前的 MorphNet 正则化损失以及采用当前提议结构时的成本。\n\n```python\ntf.summary.scalar('RegularizationLoss', regularizer_loss)\ntf.summary.scalar(network_regularizer.cost_name, network_regularizer.get_cost())\n```\n\n![TensorBoardDisplayOfFlops](g3doc\u002Ftensorboard.png \"MorphNet 正则化资源的 TensorBoard 显示示例。\")\n\n`regularization_strength` 的值越大，最终收敛到的有效 FLOP 计数就越小。如果 `regularization_strength` 足够大，FLOP 计数将降为零。相反，如果它足够小，FLOP 计数将保持初始值，网络结构也不会发生变化。`regularization_strength` 参数是您用来控制希望在价格性能曲线上所处位置的调节旋钮。`alive_threshold` 参数则用于确定激活是否处于“存活”状态。\n\n### 提取 MorphNet 学习到的架构\n\n在训练过程中，您应保存一个包含网络学习到的结构的 JSON 文件，即由 MorphNet 保留（而非移除）的某一层中激活的数量。\n\n```python\nexporter = structure_exporter.StructureExporter(\n    network_regularizer.op_regularizer_manager)\n\nwith tf.Session() as sess:\n  tf.global_variables_initializer().run()\n  for step in range(max_steps):\n    _, structure_exporter_tensors = sess.run([train_op, exporter.tensors])\n    if (step % 1000 == 0):\n      exporter.populate_tensor_values(structure_exporter_tensors)\n      exporter.create_file_and_save_alive_counts(train_dir, step)\n```\n\n## 其他\n\n联系方式：morphnet@google.com\n\n### 维护者\n\n*   Elad Eban，GitHub: [eladeban](https:\u002F\u002Fgithub.com\u002Feladeban)\n*   Andrew Poon，GitHub: [ayp-google](https:\u002F\u002Fgithub.com\u002Fayp-google)\n*   Yair Movshovitz-Attias，GitHub: [yairmov](https:\u002F\u002Fgithub.com\u002Fyairmov)\n*   Max Moroz，GitHub: [pkch](https:\u002F\u002Fgithub.com\u002Fpkch)\n\n### 贡献者\n\n*   Ariel Gordon，GitHub: [gariel-google](https:\u002F\u002Fgithub.com\u002Fgariel-google)。","# MorphNet 快速上手指南\n\nMorphNet 是一种在训练过程中学习深度网络结构的方法。它通过添加正则化项，根据资源约束（如 FLOPs、模型大小或延迟）自动调整卷积层的输出通道数量，从而实现模型压缩和架构搜索。\n\n## 环境准备\n\n*   **操作系统**: Linux, macOS, Windows (需配置好 TensorFlow 环境)\n*   **Python 版本**: 推荐 Python 3.6 - 3.8 (取决于 TensorFlow 版本兼容性)\n*   **核心依赖**:\n    *   TensorFlow 1.x (官方示例基于 TF1，若使用 TF2 需开启兼容模式或自行适配)\n    *   NumPy\n    *   Matplotlib (用于可视化)\n*   **硬件要求**: 支持 CUDA 的 NVIDIA GPU (可选，但推荐用于加速训练)\n\n> **注意**: 由于 MorphNet 主要基于 TensorFlow 1.x 开发，请确保您的环境中已正确安装 `tensorflow-gpu` (TF1 版本)。国内用户可使用清华源加速安装：\n> ```bash\n> pip install tensorflow-gpu==1.15.0 -i https:\u002F\u002Fpypi.tuna.tsinghua.edu.cn\u002Fsimple\n> ```\n\n## 安装步骤\n\n目前 MorphNet 未作为标准包发布在 PyPI 上，建议直接从 GitHub 源码安装。\n\n1.  **克隆仓库**\n    ```bash\n    git clone https:\u002F\u002Fgithub.com\u002Fgoogle-research\u002Fmorphnet.git\n    cd morphnet\n    ```\n\n2.  **安装依赖**\n    将当前目录添加到 Python 路径，或安装为可编辑模式：\n    ```bash\n    pip install -e .\n    ```\n    *(如果目录下没有 `setup.py`，请直接将 `morphnet` 文件夹复制到您的项目目录中，并确保能导入 `morph_net` 模块)*\n\n## 基本使用\n\n以下是使用 MorphNet 压缩模型 FLOPs 的最简流程。核心思想是：**结构学习训练** -> **导出结构** -> **重构并重新训练**。\n\n### 第一步：构建带正则化的模型\n\n在定义模型时，需要在激活函数后插入概率门控层（Gating Layer），并选择 `LogisticSigmoid` 正则化器（推荐方式）。\n\n```python\nimport tensorflow as tf\nfrom morph_net.network_regularizers import flop_regularizer\nfrom morph_net.tools import structure_exporter\nfrom morph_net.framework import activation_gating\n\ndef build_model(inputs, labels, is_training):\n  # 1. 定义门控激活函数 (Probabilistic Gating)\n  gated_relu = activation_gating.gated_relu_activation()\n\n  # 构建网络示例\n  net = tf.layers.conv2d(inputs, filters=256, kernel_size=[5, 5])\n  net = gated_relu(net, is_training=is_training)\n\n  # ... 中间层 ...\n\n  net = tf.layers.conv2d(net, filters=1024, kernel_size=[3, 3])\n  net = gated_relu(net, is_training=is_training)\n\n  logits = tf.reduce_mean(net, [1, 2])\n  logits = tf.layers.dense(logits, units=10)\n  return logits\n\n# 准备数据占位符\ninputs = tf.placeholder(tf.float32, shape=[None, 224, 224, 3])\nlabels = tf.placeholder(tf.int32, shape=[None])\n\nlogits = build_model(inputs, labels, is_training=True)\n\n# 2. 初始化正则化器\n# output_boundary: 从哪个节点开始向后遍历\n# input_boundary: 遇到哪些节点停止遍历 (通常不包含输入和标签)\nnetwork_regularizer = flop_regularizer.LogisticSigmoidFlopsRegularizer(\n    output_boundary=[logits.op],\n    input_boundary=[inputs.op, labels.op],\n    alive_threshold=0.1  # 阈值，决定通道是否被保留\n)\n\n# 3. 组合损失函数\nregularization_strength = 1e-10  # 正则化强度，需根据初始 FLOPs 调整 (约 1\u002Finitial_flops)\nregularizer_loss = network_regularizer.get_regularization_term() * regularization_strength\n\nbase_loss = tf.nn.sparse_softmax_cross_entropy_with_logits(labels=labels, logits=logits)\ntotal_loss = base_loss + regularizer_loss\n\n# 4. 定义优化器 (建议使用固定学习率)\noptimizer = tf.train.MomentumOptimizer(learning_rate=0.01, momentum=0.9)\ntrain_op = optimizer.minimize(total_loss)\n\n# 5. (可选) 添加 TensorBoard 监控\ntf.summary.scalar('RegularizationLoss', regularizer_loss)\ntf.summary.scalar('EstimatedFLOPs', network_regularizer.get_cost())\n```\n\n### 第二步：训练并导出结构\n\n在训练循环中，定期保存当前的网络结构配置到 JSON 文件。\n\n```python\nexporter = structure_exporter.StructureExporter(\n    network_regularizer.op_regularizer_manager)\n\nwith tf.Session() as sess:\n  sess.run(tf.global_variables_initializer())\n  \n  for step in range(max_steps):\n    # 执行训练\n    _, summary_str, exporter_tensors = sess.run(\n        [train_op, tf.summary.merge_all(), exporter.tensors]\n    )\n    \n    # 每 1000 步保存一次结构\n    if step % 1000 == 0:\n      exporter.populate_tensor_values(exporter_tensors)\n      # 生成包含各层存活通道数的 JSON 文件\n      exporter.create_file_and_save_alive_counts('.\u002Ftrain_log', step)\n      \n    # 写入 TensorBoard\n    # writer.add_summary(summary_str, step)\n```\n\n### 第三步：重构与重训练\n\n1.  **解析 JSON**: 读取上一步生成的 JSON 文件，获取每一层需要保留的通道数量。\n2.  **修改模型**: 根据 JSON 中的通道数，手动修改原始模型代码中 `conv2d` 等层的 `filters` 参数，**移除**所有的门控层（gating layers）和 MorphNet 正则化项。\n3.  **从头训练**: 使用标准的超参数（如学习率衰减策略）对裁剪后的新模型进行从头训练（Retraining），以恢复精度。\n\n> **提示**: `regularization_strength` 是控制压缩率的关键旋钮。值越大，最终模型的 FLOPs 越小；值过小则结构不会发生变化。建议在对数尺度上搜索该参数（例如围绕 `1\u002F初始 FLOPs` 上下浮动几个数量级）。","某边缘计算团队正在将高精度图像分类模型部署到算力受限的无人机摄像头中，急需降低延迟并压缩体积。\n\n### 没有 morph-net 时\n- 工程师只能依赖人工经验手动剪枝，反复尝试删除哪些卷积层通道，耗时数周且极易破坏模型精度。\n- 难以精确控制硬件指标，往往为了满足内存限制而过度剪枝，导致识别率大幅下降，或在延迟达标前无法确定最优结构。\n- 缺乏自动化流程，每次调整网络结构都需要重新设计拓扑并从头训练，开发迭代周期漫长。\n- 传统正则化方法（如 GroupLasso）对特定硬件资源（如 FLOPs 或延迟）的约束能力弱，无法直接针对目标设备进行优化。\n\n### 使用 morph-net 后\n- 通过引入 FiGS（LogisticSigmoid）正则器，morph-net 在训练过程中自动学习并抑制冗余通道，无需人工干预即可生成精简结构。\n- 直接以目标设备的延迟或 FLOPs 作为约束条件进行优化，确保最终模型严格符合无人机的硬件上限，同时最大化保留精度。\n- 保持原有网络拓扑不变，仅动态调整各层输出通道数，实现了从“种子网络”到“定制模型”的端到端自动化演进。\n- 利用连续松弛技术将结构搜索融入标准训练流程，显著缩短了从实验到部署的验证周期，提升了研发效率。\n\nmorph-net 的核心价值在于将复杂的网络结构搜索转化为带资源约束的常规训练任务，让模型在训练中自动“进化”出最适合特定硬件的形态。","https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fgoogle-research_morph-net_91fe2c73.png","google-research","Google Research","https:\u002F\u002Foss.gittoolsai.com\u002Favatars\u002Fgoogle-research_c23b2adf.png","",null,"https:\u002F\u002Fresearch.google","https:\u002F\u002Fgithub.com\u002Fgoogle-research",[83,87],{"name":84,"color":85,"percentage":86},"Python","#3572A5",95.7,{"name":88,"color":89,"percentage":90},"Starlark","#76d275",4.3,1035,152,"2026-04-02T08:38:39","Apache-2.0",4,"未说明","未说明 (基于 TensorFlow，通常支持 CUDA GPU 以加速训练，但 README 未指定具体型号或版本)",{"notes":99,"python":96,"dependencies":100},"该工具基于 TensorFlow 1.x 构建（代码示例中使用 tf.layers, tf.Session, tf.train.MomentumOptimizer 等 API）。若使用推荐的 LogisticSigmoid 正则化器，需在模型中手动添加概率门控层（gating layers）。若使用 Gamma 正则化器，必须启用 BatchNorm 的 scale 参数。工作流程分为两个阶段：首先带正则化项进行‘结构学习’训练，导出 JSON 结构文件；然后修改模型架构并从头开始‘重训练’（不带正则化项）。",[101,102],"tensorflow","tf.keras",[13],[105,106,101,107,108,109],"neural-architecture-search","automl","deep-learning","python","machine-learning","2026-03-27T02:49:30.150509","2026-04-06T08:09:04.553675",[113,118,123,128,133,137,141],{"id":114,"question_zh":115,"answer_zh":116,"source_url":117},15404,"在使用 MorphNet 进行训练时，为什么 FLOPs 没有按预期减少？","常见原因包括：1. 未将正则化损失（regularizer_loss）添加到原始损失函数中；2. 正则化器放置位置错误。请检查代码确保已将 regularizer_loss 加到总 loss 中，并确认正则化器应用在正确的位置。此外，可以尝试调整 regularization_strength 和 gamma_threshold 参数，或者为 gammas 添加衰减。","https:\u002F\u002Fgithub.com\u002Fgoogle-research\u002Fmorph-net\u002Fissues\u002F105",{"id":119,"question_zh":120,"answer_zh":121,"source_url":122},15405,"MorphNet 是否只能作用于模型的特定层（例如仅骨干网络）？","是的，MorphNet 可以作用于模型的特定层。如果某些层（如全连接层 fc）不是 conv-bn 结构，它们无法直接被 Gamma* 正则化。解决方案是使用黑名单（blacklist）排除不需要正则化的卷积层，或者仅对主要消耗计算量的部分（如 conv1）进行正则化。在某些架构中，忽略次要层（conv2, conv3, fc1, fc2）的计算成本通常是安全的，因为相对于其他元素其成本可忽略不计。","https:\u002F\u002Fgithub.com\u002Fgoogle-research\u002Fmorph-net\u002Fissues\u002F109",{"id":124,"question_zh":125,"answer_zh":126,"source_url":127},15406,"如何保存和恢复由 MorphNet 学习到的权重及结构，以避免从头重新训练？","虽然可以将学习到的结构导出为 JSON，但为了简单起见，官方建议重新初始化并从头开始重新训练（retrain from scratch），实验表明这通常不会影响最终效果。如果你尝试复用权重，必须非常小心，因为调整卷积大小后 TensorFlow 计算图会发生变化，需要正确复制张量。目前官方推荐的做法是依据生成的 JSON 更新模型定义后，使用新的超参数从头训练精简版模型。","https:\u002F\u002Fgithub.com\u002Fgoogle-research\u002Fmorph-net\u002Fissues\u002F68",{"id":129,"question_zh":130,"answer_zh":131,"source_url":132},15407,"遇到 'ValueError: Total size for op slices do not match' 错误该如何解决？","该错误通常发生在处理多输出或特定的 Concat 操作时。首先，确认 MorphNet 已支持轴（axis）不为 3（或 -1）的 Concat 操作。调试建议：1. 尝试分别对不同的输出操作符单独运行正则化器（例如只传入 cls_pred.op 或 box_pred.op），以定位具体是哪个分支导致错误；2. 检查涉及动态 RNN 或 GRU 结构的 Concat 操作，确保其后的 BatchNorm 结构正确添加。如果问题依旧，可能需要检查输入输出切片尺寸是否对齐。","https:\u002F\u002Fgithub.com\u002Fgoogle-research\u002Fmorph-net\u002Fissues\u002F54",{"id":134,"question_zh":135,"answer_zh":136,"source_url":117},15408,"为什么我的 JSON 文件中卷积层通道数减少了，但整体 FLOPs 却在增加？","这种情况可能与权重（weight）和偏置（bias）的处理有关。MorphNet 主要改变权重通道，但需确认偏置是否也被正确转移或处理。此外，如果某些未被剪枝的层（如全连接层）因输入通道依赖关系而保持不变，或者由于正则化强度设置不当导致其他层补偿性增长，都可能导致 FLOPs 不降反升。建议检查直方图中 gamma 值的变化，并尝试增大正则化强度（regularization_strength）或将 gamma_threshold 固定在较高值（如 0.88）。",{"id":138,"question_zh":139,"answer_zh":140,"source_url":127},15409,"在重新训练剪枝后的模型时，应该使用什么样的超参数？","对于重新训练剪枝后的模型（例如基于 ResNet V1 50），官方建议从头初始化权重。关于超参数，虽然没有固定的标准值，但用户反馈表明收敛可能比较困难。建议参考原论文或相关实验设置，尝试调整学习率、批次大小等参数。如果有用户成功收敛，通常会使用 TF Slim 库进行实验。关键在于根据新生成的网络结构重新搜索合适的超参数组合，因为原有的超参数可能不再适用。",{"id":142,"question_zh":143,"answer_zh":144,"source_url":122},15410,"如何同时正则化卷积层和全连接层以获得更大的 FLOPs 优化？","标准的 Gamma* 正则化主要针对带有 BatchNorm 的卷积层。全连接层（FC）由于不是 conv-bn 结构，默认不会被正则化，这限制了整体优化效果。理论上，如果能同时正则化 conv 和 fc 层可以获得更大收益，但这需要自定义实现或使用特定的扩展方法。目前的变通方案是利用黑名单机制排除受 FC 层限制的卷积层，或者接受 FC 层成本相对较小的事实，仅优化主要的卷积部分。",[]]