[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"similar-microsoft--tensorwatch":3,"tool-microsoft--tensorwatch":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":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":80,"owner_twitter":81,"owner_website":82,"owner_url":83,"languages":84,"stars":97,"forks":98,"last_commit_at":99,"license":100,"difficulty_score":23,"env_os":101,"env_gpu":101,"env_ram":101,"env_deps":102,"category_tags":109,"github_topics":110,"view_count":23,"oss_zip_url":79,"oss_zip_packed_at":79,"status":16,"created_at":129,"updated_at":130,"faqs":131,"releases":157},2176,"microsoft\u002Ftensorwatch","tensorwatch","Debugging, monitoring and visualization for Python Machine Learning and Data Science","TensorWatch 是微软研究院推出的一款专为 Python 机器学习与数据科学打造的调试、监控及可视化工具。它主要解决了开发者在模型训练过程中难以实时洞察内部状态、排查复杂错误以及直观分析数据流的痛点。\n\n这款工具特别适合从事深度学习、强化学习研究的科研人员，以及需要在 Jupyter Notebook 环境中进行高效开发的算法工程师。与普通日志工具不同，TensorWatch 不仅能实时展示训练图表和网络结构，更拥有独特的“惰性日志模式”（Lazy Logging Mode）。该功能允许用户向正在运行的训练进程发送任意查询指令，动态获取数据流并自定义可视化方式，实现了真正的交互式调试。此外，它还支持高度扩展，用户可以轻松构建个性化的仪表盘和界面。\n\n需要注意的是，TensorWatch 定位为强大的研发辅助工具，因其设计包含执行动态代码的能力，官方建议仅在受信任的开发环境中使用，避免直接部署于生产或多租户场景。对于希望深入理解模型行为、提升调试效率的技术人员而言，TensorWatch 是一个灵活且功能强大的得力助手。","# Welcome to TensorWatch\r\n\r\nTensorWatch is a debugging and visualization tool designed for data science, deep learning and reinforcement learning from Microsoft Research. It works in Jupyter Notebook to show real-time visualizations of your machine learning training and perform several other key analysis tasks for your models and data.\r\n\r\nTensorWatch is designed to be flexible and extensible so you can also build your own custom visualizations, UIs, and dashboards. Besides traditional \"what-you-see-is-what-you-log\" approach, it also has a unique capability to execute arbitrary queries against your live ML training process, return a stream as a result of the query and view this stream using your choice of a visualizer (we call this [Lazy Logging Mode](#lazy-logging-mode])).\r\n\r\nTensorWatch is under heavy development with a goal of providing a platform for debugging machine learning in one easy to use, extensible, and hackable package.\r\n\r\n\u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fmicrosoft_tensorwatch_readme_73bfde95b456.gif\" alt=\"TensorWatch in Jupyter Notebook\" width=\"400\"\u002F>\r\n\r\n## How to Get It\r\n\r\n```\r\npip install tensorwatch\r\n```\r\n\r\nTensorWatch supports Python 3.x and is tested with PyTorch 0.4-1.x. Most features should also work with TensorFlow eager tensors. TensorWatch uses graphviz to create network diagrams and depending on your platform sometime you might need to manually [install](https:\u002F\u002Fgraphviz.gitlab.io\u002Fdownload\u002F) it.\r\n\r\n### Security Notice\r\n\r\n> **⚠ Important: TensorWatch is a development and debugging tool. It is not\r\n> designed for production, multi-tenant, or adversarial environments.**\r\n>\r\n> TensorWatch has several features that, by design, can execute arbitrary code.\r\n> Users must understand these risks before deploying it.\r\n>\r\n> #### 1. Lazy Logging — `eval()` on Network-Supplied Expressions (CWE-94)\r\n>\r\n> The Lazy Logging feature (`create_stream(expr=...)`) sends a Python expression\r\n> from a `WatcherClient` to a `Watcher` server over ZeroMQ. The server executes\r\n> this expression via Python's `eval()` (in `evaler.py`). **This is by design**\r\n> — it enables interactive debugging by letting clients query the live training\r\n> process with arbitrary Python expressions. However, any authenticated client\r\n> that can connect to the Watcher's ZMQ port can execute arbitrary Python code\r\n> in the Watcher process.\r\n>\r\n> **Mitigations in place:**\r\n> - Messages are HMAC-SHA256 signed; only processes sharing the key can send\r\n>   expressions.\r\n> - The Watcher binds to `127.0.0.1` (localhost) by default, preventing remote\r\n>   connections unless explicitly configured otherwise.\r\n>\r\n> **User responsibilities:**\r\n> - **Do not expose TensorWatch ports to untrusted networks or users.**\r\n> - In multi-process setups (separate Watcher and WatcherClient processes), set\r\n>   `ZmqWrapper._hmac_key` to a shared secret before calling `initialize()` so\r\n>   that HMAC authentication is effective across processes.\r\n> - Do not run TensorWatch on machines where untrusted users have local network\r\n>   access.\r\n>\r\n> #### 2. Pickle Deserialization — Network (CWE-502)\r\n>\r\n> All ZeroMQ messages are serialized\u002Fdeserialized using Python's `pickle`\r\n> module. Pickle deserialization can execute arbitrary code if given a crafted\r\n> payload.\r\n>\r\n> **Mitigations in place:**\r\n> - All incoming ZMQ messages are HMAC-SHA256 verified **before**\r\n>   deserialization (`ZmqWrapper.verify_and_loads`). Messages with invalid\r\n>   signatures are rejected without being deserialized.\r\n> - A `RestrictedUnpickler` uses an **allowlist** of permitted modules\r\n>   (builtins, collections, numpy, torch, pandas, tensorwatch, and pickle\r\n>   internals) as defense-in-depth. Any module not explicitly approved is\r\n>   blocked, which is significantly stronger than the previous blocklist\r\n>   approach.\r\n> - For multi-process setups, set the `TENSORWATCH_HMAC_KEY` environment\r\n>   variable to a shared hex-encoded secret (e.g.\r\n>   `export TENSORWATCH_HMAC_KEY=$(python -c \"import os; print(os.urandom(32).hex())\")`).\r\n>   Alternatively, set `ZmqWrapper._hmac_key` directly in code before\r\n>   calling `initialize()`.\r\n>\r\n> **User responsibilities:**\r\n> - Ensure the HMAC key is kept secret and shared only with trusted processes.\r\n> - Do not expose ZMQ ports to untrusted networks.\r\n>\r\n> #### 3. Pickle Deserialization — Files (CWE-502)\r\n>\r\n> `FileStream` (in `file_stream.py`) uses `pickle.load()` to read stream data\r\n> from files. A crafted pickle file can execute arbitrary code when loaded.\r\n>\r\n> **Mitigations in place:**\r\n> - A `RestrictedUnpickler` uses an **allowlist** of permitted modules\r\n>   as defense-in-depth. Only modules TensorWatch needs (builtins,\r\n>   collections, numpy, torch, pandas, tensorwatch) are allowed; all\r\n>   others are blocked by default.\r\n>\r\n> **User responsibilities:**\r\n> - **Only open TensorWatch data files (`.log`, `.pkl`) that you created\r\n>   yourself or that come from a source you fully trust.**\r\n> - Treat TensorWatch data files with the same caution as executable scripts.\r\n>\r\n> #### 4. YAML Deserialization\r\n>\r\n> The bundled `hiddenlayer` utilities include YAML loading functions. These use\r\n> `yaml.SafeLoader` by default to prevent arbitrary Python object instantiation\r\n> from YAML files. Do not override the loader with `yaml.Loader` or\r\n> `yaml.UnsafeLoader` when processing untrusted YAML input.\r\n>\r\n> #### 5. Summary of Precautions\r\n>\r\n> | Risk | Mitigation | User Action |\r\n> |------|-----------|-------------|\r\n> | `eval()` on expressions from clients | HMAC auth + localhost binding | Never expose ports to untrusted networks |\r\n> | `pickle.loads()` from ZMQ | HMAC + allowlist RestrictedUnpickler | Keep HMAC key secret |\r\n> | `pickle.load()` from files | Allowlist RestrictedUnpickler (defense-in-depth) | Only load trusted files |\r\n> | YAML deserialization | `yaml.SafeLoader` by default | Do not override with unsafe loaders |\r\n> | ZMQ port exposure | Binds to `127.0.0.1` by default | Do not change to `0.0.0.0` in untrusted environments |\r\n\r\n## How to Use It\r\n\r\n### Quick Start\r\n\r\nHere's simple code that logs an integer and its square as a tuple every second to TensorWatch:\r\n```\r\nimport tensorwatch as tw\r\nimport time\r\n\r\n# streams will be stored in test.log file\r\nw = tw.Watcher(filename='test.log')\r\n\r\n# create a stream for logging\r\ns = w.create_stream(name='metric1')\r\n\r\n# generate Jupyter Notebook to view real-time streams\r\nw.make_notebook()\r\n\r\nfor i in range(1000):\r\n    # write x,y pair we want to log\r\n    s.write((i, i*i))\r\n\r\n    time.sleep(1)\r\n```\r\nWhen you run this code, you will notice a Jupyter Notebook file `test.ipynb` gets created in your script folder. From a command prompt type `jupyter notebook` and select `test.ipynb`. Choose *Cell > Run all* in the menu to see the real-time line graph as values get written in your script.\r\n\r\nHere's the output you will see in Jupyter Notebook:\r\n\r\n\u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fmicrosoft_tensorwatch_readme_24cccc537860.gif\" alt=\"TensorWatch in Jupyter Notebook\" width=\"250\"\u002F>\r\n\r\nTo dive deeper into the various other features, please see [Tutorials](#tutorials) and [notebooks](https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Ftensorwatch\u002Ftree\u002Fmaster\u002Fnotebooks).\r\n\r\n### How does this work?\r\n\r\nWhen you write to a TensorWatch stream, the values get serialized and sent to a TCP\u002FIP socket as well as the file you specified. From Jupyter Notebook, we load the previously logged values from the file and then listen to that TCP\u002FIP socket for any future values. The visualizer listens to the stream and renders the values as they arrive.\r\n\r\nOk, so that's a very simplified description. The TensorWatch architecture is actually much more powerful. Almost everything in TensorWatch is a *stream*. Files, sockets, consoles and even visualizers are streams themselves. A cool thing about TensorWatch streams is that they can listen to any other streams. This allows TensorWatch to create a *data flow graph*. This means that a visualizer can listen to many streams simultaneously, each of which could be a file, a socket or some other stream. You can recursively extend this to build arbitrary data flow graphs. TensorWatch decouples streams from how they get stored and how they get visualized.\r\n\r\n## Visualizations\r\nIn the above example, the line graph is used as the default visualization. However, TensorWatch supports many other diagram types including histograms, pie charts, scatter charts, bar charts and 3D versions of many of these plots. You can log your data, specify the chart type you want and let TensorWatch take care of the rest.\r\n\r\nOne of the significant strengths of TensorWatch is the ability to combine, compose, and create custom visualizations effortlessly. For example, you can choose to visualize an arbitrary number of streams in the same plot. Or you can visualize the same stream in many different plots *simultaneously*. Or you can place an arbitrary set of visualizations side-by-side. You can even create your own custom visualization widget simply by creating a new Python class, implementing a few methods.\r\n\r\n## Comparing Results of Multiple Runs\r\nEach TensorWatch stream may contain a metric of your choice. By default, TensorWatch saves all streams in a single file, but you could also choose to save each stream in separate files or not to save them at all (for example, sending streams over sockets or into the console directly, zero hit to disk!). Later you can open these streams and direct them to one or more visualizations. This design allows you to quickly compare the results from your different experiments in your choice of visualizations easily.\r\n\r\n## Training within Jupyter Notebook\r\nOften you might prefer to do data analysis, ML training, and testing - all from within Jupyter Notebook instead of from a separate script. TensorWatch can help you do sophisticated, real-time visualizations effortlessly from code that is run within a Jupyter Notebook end-to-end.\r\n\r\n## Lazy Logging Mode\r\nA unique feature in TensorWatch is the ability to query the live running process, retrieve the result of this query as a stream and direct this stream to your preferred visualization(s). You don't need to log any data beforehand. We call this new way of debugging and visualization a *lazy logging mode*.\r\n\r\nFor example, as seen below, we visualize input and output image pairs, sampled randomly during the training of an autoencoder on a fruits dataset. These images were not logged beforehand in the script. Instead, the user sends query as a Python lambda expression which results in a stream of images that gets displayed in the Jupyter Notebook:\r\n\r\n\u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fmicrosoft_tensorwatch_readme_94d88ad9d1dd.gif\" alt=\"TensorWatch in Jupyter Notebook\" width=\"200\"\u002F>\r\n\r\nSee [Lazy Logging Tutorial](https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Ftensorwatch\u002Fblob\u002Fmaster\u002Fdocs\u002Flazy_logging.md).\r\n\r\n### Pre-Training and Post-Training Tasks\r\n\r\nTensorWatch leverages several excellent libraries including [hiddenlayer](https:\u002F\u002Fgithub.com\u002Fwaleedka\u002Fhiddenlayer), [torchstat](https:\u002F\u002Fgithub.com\u002FSwall0w\u002Ftorchstat), [Visual Attribution](https:\u002F\u002Fgithub.com\u002Fyulongwang12\u002Fvisual-attribution) to allow performing the usual debugging and analysis activities in one consistent package and interface.\r\n\r\nFor example, you can view the model graph with tensor shapes with a one-liner:\r\n\r\n\u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fmicrosoft_tensorwatch_readme_2e15f984f420.png\" alt=\"Model graph for Alexnet\" width=\"400\"\u002F>\r\n\r\nYou can view statistics for different layers such as flops, number of parameters, etc:\r\n\r\n\u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fmicrosoft_tensorwatch_readme_3ee85514eac6.png\" alt=\"Model statistics for Alexnet\" width=\"600\"\u002F>\r\n\r\n[See notebook](https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Ftensorwatch\u002Fblob\u002Fmaster\u002Fnotebooks\u002Fnetwork_arch.ipynb).\r\n\r\nYou can view the dataset in a lower dimensional space using techniques such as t-SNE:\r\n\r\n\u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fmicrosoft_tensorwatch_readme_62a52614ede9.gif\" alt=\"t-SNE visualization for MNIST\" width=\"400\"\u002F>\r\n\r\n[See notebook](https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Ftensorwatch\u002Fblob\u002Fmaster\u002Fnotebooks\u002Fdata_exploration.ipynb).\r\n\r\n### Prediction Explanations\r\nWe wish to provide various tools for explaining predictions to help debugging models. Currently, we offer several explainers for convolutional networks, including [Lime](https:\u002F\u002Fgithub.com\u002Fmarcotcr\u002Flime). For example, the following highlights the areas that cause the Resnet50 model to make a prediction for class 240 for the Imagenet dataset:\r\n\r\n\u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fmicrosoft_tensorwatch_readme_712a1b252de1.png\" alt=\"CNN prediction explanation\" width=\"300\"\u002F>\r\n\r\n[See notebook](https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Ftensorwatch\u002Fblob\u002Fmaster\u002Fnotebooks\u002Fcnn_pred_explain.ipynb).\r\n\r\n\r\n## Tutorials\r\n\r\n- [Simple Logging Tutorial](https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Ftensorwatch\u002Fblob\u002Fmaster\u002Fdocs\u002Fsimple_logging.md)\r\n\r\n- [Lazy Logging Tutorial](https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Ftensorwatch\u002Fblob\u002Fmaster\u002Fdocs\u002Flazy_logging.md)\r\n\r\n- [Using TensorWatch for Deep Learning Training (MNIST)](https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Ftensorwatch\u002Fblob\u002Fmaster\u002Fnotebooks\u002Fmnist.ipynb)\r\n\r\n- [Using TensorWatch for Deep Learning Training (Food360)](https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Ftensorwatch\u002Fblob\u002Fmaster\u002Fnotebooks\u002Ffruits_analysis.ipynb)\r\n\r\n- [Exploring Data Using T-SNE](https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Ftensorwatch\u002Fblob\u002Fmaster\u002Fnotebooks\u002Fdata_exploration.ipynb)\r\n\r\n- [Predication Explainers for Convolutional Neural Networks](https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Ftensorwatch\u002Fblob\u002Fmaster\u002Fnotebooks\u002Fcnn_pred_explain.ipynb)\r\n\r\n- [Viewing Model Graph and Statistics](https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Ftensorwatch\u002Fblob\u002Fmaster\u002Fnotebooks\u002Fnetwork_arch.ipynb)\r\n\r\n## Paper\r\n\r\nMore technical details are available in [TensorWatch paper (EICS 2019 Conference)](https:\u002F\u002Farxiv.org\u002Fabs\u002F2001.01215). Please cite this as:\r\n\r\n```\r\n@inproceedings{tensorwatch2019eics,\r\n  author    = {Shital Shah and Roland Fernandez and Steven M. Drucker},\r\n  title     = {A system for real-time interactive analysis of deep learning training},\r\n  booktitle = {Proceedings of the {ACM} {SIGCHI} Symposium on Engineering Interactive\r\n               Computing Systems, {EICS} 2019, Valencia, Spain, June 18-21, 2019},\r\n  pages     = {16:1--16:6},\r\n  year      = {2019},\r\n  crossref  = {DBLP:conf\u002Feics\u002F2019},\r\n  url       = {https:\u002F\u002Farxiv.org\u002Fabs\u002F2001.01215},\r\n  doi       = {10.1145\u002F3319499.3328231},\r\n  timestamp = {Fri, 31 May 2019 08:40:31 +0200},\r\n  biburl    = {https:\u002F\u002Fdblp.org\u002Frec\u002Fbib\u002Fconf\u002Feics\u002FShahFD19},\r\n  bibsource = {dblp computer science bibliography, https:\u002F\u002Fdblp.org}\r\n}\r\n```\r\n\r\n## Contribute\r\n\r\nWe would love your contributions, feedback, questions, and feature requests! Please [file a Github issue](https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Ftensorwatch\u002Fissues\u002Fnew) or send us a pull request. Please review the [Microsoft Code of Conduct](https:\u002F\u002Fopensource.microsoft.com\u002Fcodeofconduct\u002F) and [learn more](https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Ftensorwatch\u002Fblob\u002Fmaster\u002FCONTRIBUTING.md).\r\n\r\n## Contact\r\n\r\nJoin the TensorWatch group on [Facebook](https:\u002F\u002Fwww.facebook.com\u002Fgroups\u002F378075159472803\u002F) to stay up to date or ask any questions.\r\n\r\n## Credits\r\n\r\nTensorWatch utilizes several open source libraries for many of its features. These include: [hiddenlayer](https:\u002F\u002Fgithub.com\u002Fwaleedka\u002Fhiddenlayer), [torchstat](https:\u002F\u002Fgithub.com\u002FSwall0w\u002Ftorchstat), [Visual-Attribution](https:\u002F\u002Fgithub.com\u002Fyulongwang12\u002Fvisual-attribution), [pyzmq](https:\u002F\u002Fgithub.com\u002Fzeromq\u002Fpyzmq), [receptivefield](https:\u002F\u002Fgithub.com\u002Ffornaxai\u002Freceptivefield), [nbformat](https:\u002F\u002Fgithub.com\u002Fjupyter\u002Fnbformat). Please see `install_requires` section in [setup.py](setup.py) for upto date list.\r\n\r\n## License\r\n\r\nThis project is released under the MIT License. Please review the [License file](LICENSE.txt) for more details.\r\n","# 欢迎来到 TensorWatch\n\nTensorWatch 是由微软研究院开发的一款专为数据科学、深度学习和强化学习设计的调试与可视化工具。它可以在 Jupyter Notebook 中运行，实时展示您的机器学习训练过程，并为您的模型和数据执行多种关键分析任务。\n\nTensorWatch 设计灵活且可扩展，因此您也可以构建自己的自定义可视化、用户界面和仪表板。除了传统的“所见即所记”方式外，它还具备一项独特功能：可以对正在运行的机器学习训练过程执行任意查询，将查询结果以流的形式返回，并使用您选择的可视化工具来查看这些数据（我们称之为 [懒加载模式](#lazy-logging-mode)）。\n\nTensorWatch 目前正处于积极开发中，目标是提供一个易于使用、可扩展且可自由修改的平台，用于机器学习的调试工作。\n\n\u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fmicrosoft_tensorwatch_readme_73bfde95b456.gif\" alt=\"TensorWatch 在 Jupyter Notebook 中\" width=\"400\"\u002F>\n\n## 如何获取\n\n```bash\npip install tensorwatch\n```\n\nTensorWatch 支持 Python 3.x，并已在 PyTorch 0.4–1.x 上进行了测试。大多数功能也应适用于 TensorFlow 的 eager 张量。TensorWatch 使用 graphviz 来生成网络图，根据您的平台不同，有时可能需要手动 [安装](https:\u002F\u002Fgraphviz.gitlab.io\u002Fdownload\u002F) 它。\n\n### 安全声明\n\n> **⚠ 重要提示：TensorWatch 是一款开发和调试工具，不适用于生产环境、多租户环境或对抗性环境。**\n>\n> TensorWatch 具备若干功能，按设计可执行任意代码。用户在部署之前必须充分了解这些风险。\n>\n> #### 1. 懒加载 — 对网络提供的表达式进行 `eval()` 调用 (CWE-94)\n>\n> 懒加载功能 (`create_stream(expr=...)`) 会通过 ZeroMQ 将 Python 表达式从 `WatcherClient` 发送到 `Watcher` 服务器。服务器会通过 Python 的 `eval()` 函数执行该表达式（位于 `evaler.py` 文件中）。**这是设计使然**，它允许客户端使用任意 Python 表达式查询正在运行的训练过程，从而实现交互式调试。然而，任何能够连接到 Watcher 的 ZMQ 端口并经过身份验证的客户端，都可在 Watcher 进程中执行任意 Python 代码。\n>\n> **已采取的缓解措施：**\n> - 所有消息均采用 HMAC-SHA256 签名；只有共享密钥的进程才能发送表达式。\n> - Watcher 默认绑定到 `127.0.0.1`（本地回环地址），从而阻止远程连接，除非明确配置为其他地址。\n>\n> **用户责任：**\n> - **请勿将 TensorWatch 的端口暴露给不受信任的网络或用户。**\n> - 在多进程设置中（即 Watcher 和 WatcherClient 分别运行在不同进程中），请在调用 `initialize()` 之前将 `ZmqWrapper._hmac_key` 设置为共享密钥，以确保跨进程的 HMAC 认证有效。\n> - 请勿在存在不受信任用户本地网络访问权限的机器上运行 TensorWatch。\n>\n> #### 2. Pickle 反序列化 — 网络 (CWE-502)\n>\n> 所有 ZeroMQ 消息均使用 Python 的 `pickle` 模块进行序列化和反序列化。如果收到精心构造的负载，Pickle 反序列化可能会执行任意代码。\n>\n> **已采取的缓解措施：**\n> - 所有传入的 ZMQ 消息都会在反序列化 **之前** 进行 HMAC-SHA256 验证（位于 `ZmqWrapper.verify_and_loads` 中）。签名无效的消息将被拒绝，不会进行反序列化。\n> - `RestrictedUnpickler` 使用一个 **允许列表** 来限制可加载的模块范围（包括内置模块、collections、numpy、torch、pandas、tensorwatch 以及 pickle 内部模块），作为纵深防御机制。任何未明确批准的模块都将被阻止，这比之前的黑名单方法更为严格。\n> - 对于多进程设置，请将 `TENSORWATCH_HMAC_KEY` 环境变量设置为一个共享的十六进制编码密钥（例如：`export TENSORWATCH_HMAC_KEY=$(python -c \"import os; print(os.urandom(32).hex())\")`）。或者，您也可以在调用 `initialize()` 之前直接在代码中设置 `ZmqWrapper._hmac_key`。\n>\n> **用户责任：**\n> - 确保 HMAC 密钥保持机密，仅与受信任的进程共享。\n> - 请勿将 ZMQ 端口暴露给不受信任的网络。\n>\n> #### 3. Pickle 反序列化 — 文件 (CWE-502)\n>\n> `FileStream`（位于 `file_stream.py` 中）使用 `pickle.load()` 从文件中读取流数据。如果文件经过恶意构造，加载时可能会执行任意代码。\n>\n> **已采取的缓解措施：**\n> - `RestrictedUnpickler` 使用一个 **允许列表** 作为纵深防御机制。只有 TensorWatch 所需的模块（内置模块、collections、numpy、torch、pandas、tensorwatch）才被允许加载；其他模块默认会被阻止。\n>\n> **用户责任：**\n> - **请仅打开由您自己创建或来自完全可信来源的 TensorWatch 数据文件（`.log`、`.pkl`）。**\n> - 处理 TensorWatch 数据文件时，请像对待可执行脚本一样谨慎。\n>\n> #### 4. YAML 反序列化\n>\n> 附带的 `hiddenlayer` 工具包含 YAML 加载函数。这些函数默认使用 `yaml.SafeLoader`，以防止从 YAML 文件中实例化任意 Python 对象。处理不受信任的 YAML 输入时，请勿将加载器替换为 `yaml.Loader` 或 `yaml.UnsafeLoader`。\n>\n> #### 5. 预防措施总结\n>\n> | 风险 | 缓解措施 | 用户行动 |\n> |------|-----------|-------------|\n> | 对客户端提供的表达式执行 `eval()` | HMAC 认证 + 绑定到本地回环地址 | 切勿将端口暴露给不受信任的网络 |\n> | 从 ZMQ 反序列化 `pickle.loads()` | HMAC + 允许列表 RestrictedUnpickler | 保持 HMAC 密钥机密 |\n> | 从文件反序列化 `pickle.load()` | 允许列表 RestrictedUnpickler（纵深防御） | 仅加载受信任的文件 |\n> | YAML 反序列化 | 默认使用 `yaml.SafeLoader` | 不要替换为不安全的加载器 |\n> | ZMQ 端口暴露 | 默认绑定到 `127.0.0.1` | 在不受信任的环境中不要更改为 `0.0.0.0` |\n\n## 如何使用\n\n### 快速入门\n\n以下是一段简单的代码，每秒将一个整数及其平方以元组形式记录到 TensorWatch 中：\n```python\nimport tensorwatch as tw\nimport time\n\n# 流数据将存储在 test.log 文件中\nw = tw.Watcher(filename='test.log')\n\n# 创建一个用于日志记录的流\ns = w.create_stream(name='metric1')\n\n# 生成 Jupyter Notebook 以查看实时流\nw.make_notebook()\n\nfor i in range(1000):\n    # 写入我们想要记录的 x, y 对\n    s.write((i, i*i))\n\n    time.sleep(1)\n```\n运行这段代码后，您会发现脚本文件夹中创建了一个名为 `test.ipynb` 的 Jupyter Notebook 文件。在命令提示符中输入 `jupyter notebook`，然后选择 `test.ipynb`。从菜单中选择 *Cell > Run all*，即可在脚本写入值时看到实时折线图。\n\n以下是您将在 Jupyter Notebook 中看到的输出：\n\n\u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fmicrosoft_tensorwatch_readme_24cccc537860.gif\" alt=\"TensorWatch 在 Jupyter Notebook 中\" width=\"250\"\u002F>\n\n要深入了解其他各种功能，请参阅 [教程](#tutorials) 和 [notebooks](https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Ftensorwatch\u002Ftree\u002Fmaster\u002Fnotebooks)。\n\n### 这究竟是如何工作的？\n\n当您向 TensorWatch 流写入数据时，这些值会被序列化并通过 TCP\u002FIP 套接字以及您指定的文件发送出去。在 Jupyter Notebook 中，我们会从文件中加载先前记录的值，然后监听该 TCP\u002FIP 套接字以获取未来的值。可视化工具会监听该流，并在数据到达时将其渲染出来。\n\n当然，以上只是一个非常简化的描述。实际上，TensorWatch 的架构要强大得多。TensorWatch 中几乎一切都是“流”。文件、套接字、控制台，甚至可视化工具本身也都是流。TensorWatch 流的一个很酷之处在于，它们可以监听任何其他流。这使得 TensorWatch 能够构建一个“数据流图”。这意味着一个可视化工具可以同时监听多个流，而每个流都可以是文件、套接字或其他类型的流。您可以递归地扩展这种结构，构建任意的数据流图。TensorWatch 将流与其存储方式和可视化方式解耦开来。\n\n## 可视化\n在上面的例子中，折线图被用作默认的可视化方式。然而，TensorWatch 还支持许多其他类型的图表，包括直方图、饼图、散点图、条形图，以及这些图表的 3D 版本。您只需记录数据并指定所需的图表类型，剩下的工作就交给 TensorWatch 来完成。\n\nTensorWatch 的一大优势在于，它可以轻松地组合、构建和创建自定义可视化。例如，您可以选择在同一张图中可视化任意数量的流；也可以让同一个流同时出现在多张不同的图中；或者将任意一组可视化并排摆放。您甚至可以通过创建一个新的 Python 类并实现几个方法，来打造属于自己的自定义可视化组件。\n\n## 比较多次运行的结果\n每个 TensorWatch 流都可以包含您选择的指标。默认情况下，TensorWatch 会将所有流保存在一个文件中，但您也可以选择将每个流保存到单独的文件中，或者完全不保存（例如直接通过套接字或控制台发送流，从而避免对磁盘的任何写入）。之后，您可以打开这些流，并将它们导向一个或多个可视化工具。这种设计使您能够轻松地使用自己选择的可视化方式，快速比较不同实验的结果。\n\n## 在 Jupyter Notebook 中进行训练\n通常，您可能更倾向于在 Jupyter Notebook 中完成数据分析、机器学习训练和测试，而不是使用单独的脚本。TensorWatch 可以帮助您在 Jupyter Notebook 中无缝地执行复杂的实时可视化操作。\n\n## 懒惰日志模式\nTensorWatch 的一项独特功能是，它能够查询正在运行的进程，将查询结果作为流返回，并将该流导向您偏好的可视化工具。您无需事先记录任何数据。我们将这种新的调试和可视化方式称为“懒惰日志模式”。\n\n例如，如下所示，我们在对水果数据集上的自编码器进行训练时，随机采样了输入和输出图像对，并进行了可视化。这些图像并未事先在脚本中记录下来。相反，用户通过一个 Python 匿名函数（lambda 表达式）发送查询，从而生成了一个图像流，并在 Jupyter Notebook 中显示出来：\n\n\u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fmicrosoft_tensorwatch_readme_94d88ad9d1dd.gif\" alt=\"TensorWatch 在 Jupyter Notebook 中\" width=\"200\"\u002F>\n\n请参阅 [懒惰日志教程](https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Ftensorwatch\u002Fblob\u002Fmaster\u002Fdocs\u002Flazy_logging.md)。\n\n### 训练前与训练后任务\n\nTensorWatch 利用多个优秀的库，包括 [hiddenlayer](https:\u002F\u002Fgithub.com\u002Fwaleedka\u002Fhiddenlayer)、[torchstat](https:\u002F\u002Fgithub.com\u002FSwall0w\u002Ftorchstat) 和 [Visual Attribution](https:\u002F\u002Fgithub.com\u002Fyulongwang12\u002Fvisual-attribution)，将常见的调试和分析任务整合到一个一致的软件包和界面中。\n\n例如，您只需一行代码即可查看带有张量形状的模型图：\n\n\u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fmicrosoft_tensorwatch_readme_2e15f984f420.png\" alt=\"Alexnet 的模型图\" width=\"400\"\u002F>\n\n您还可以查看不同层的统计信息，如浮点运算次数、参数数量等：\n\n\u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fmicrosoft_tensorwatch_readme_3ee85514eac6.png\" alt=\"Alexnet 的模型统计信息\" width=\"600\"\u002F>\n\n[查看笔记本](https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Ftensorwatch\u002Fblob\u002Fmaster\u002Fnotebooks\u002Fnetwork_arch.ipynb)。\n\n您还可以使用 t-SNE 等技术，将数据集映射到低维空间进行可视化：\n\n\u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fmicrosoft_tensorwatch_readme_62a52614ede9.gif\" alt=\"MNIST 数据集的 t-SNE 可视化\" width=\"400\"\u002F>\n\n[查看笔记本](https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Ftensorwatch\u002Fblob\u002Fmaster\u002Fnotebooks\u002Fdata_exploration.ipynb)。\n\n### 预测解释\n我们希望提供多种工具来解释模型的预测结果，以帮助调试模型。目前，我们为卷积神经网络提供了几种解释器，其中包括 [Lime](https:\u002F\u002Fgithub.com\u002Fmarcotcr\u002Flime)。例如，以下示意图突出显示了导致 ResNet50 模型对 ImageNet 数据集中的第 240 类做出预测的关键区域：\n\n\u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fmicrosoft_tensorwatch_readme_712a1b252de1.png\" alt=\"CNN 预测解释\" width=\"300\"\u002F>\n\n[查看笔记本](https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Ftensorwatch\u002Fblob\u002Fmaster\u002Fnotebooks\u002Fcnn_pred_explain.ipynb)。\n\n## 教程\n\n- [简单日志记录教程](https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Ftensorwatch\u002Fblob\u002Fmaster\u002Fdocs\u002Fsimple_logging.md)\n\n- [延迟日志记录教程](https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Ftensorwatch\u002Fblob\u002Fmaster\u002Fdocs\u002Flazy_logging.md)\n\n- [使用 TensorWatch 进行深度学习训练（MNIST）](https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Ftensorwatch\u002Fblob\u002Fmaster\u002Fnotebooks\u002Fmnist.ipynb)\n\n- [使用 TensorWatch 进行深度学习训练（Food360）](https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Ftensorwatch\u002Fblob\u002Fmaster\u002Fnotebooks\u002Ffruits_analysis.ipynb)\n\n- [使用 T-SNE 探索数据](https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Ftensorwatch\u002Fblob\u002Fmaster\u002Fnotebooks\u002Fdata_exploration.ipynb)\n\n- [卷积神经网络的预测解释器](https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Ftensorwatch\u002Fblob\u002Fmaster\u002Fnotebooks\u002Fcnn_pred_explain.ipynb)\n\n- [查看模型图和统计信息](https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Ftensorwatch\u002Fblob\u002Fmaster\u002Fnotebooks\u002Fnetwork_arch.ipynb)\n\n## 论文\n\n更多技术细节请参阅 [TensorWatch 论文（EICS 2019 大会）](https:\u002F\u002Farxiv.org\u002Fabs\u002F2001.01215)。引用格式如下：\n\n```plaintext\n@inproceedings{tensorwatch2019eics,\n  author    = {Shital Shah 和 Roland Fernandez 和 Steven M. Drucker},\n  title     = {用于深度学习训练实时交互式分析的系统},\n  booktitle = {ACM SIGCHI 工程交互计算系统研讨会论文集，EICS 2019，西班牙瓦伦西亚，2019年6月18日至21日},\n  pages     = {16:1--16:6},\n  year      = {2019},\n  crossref  = {DBLP:conf\u002Feics\u002F2019},\n  url       = {https:\u002F\u002Farxiv.org\u002Fabs\u002F2001.01215},\n  doi       = {10.1145\u002F3319499.3328231},\n  timestamp = {2019年5月31日，星期五，08:40:31 +0200},\n  biburl    = {https:\u002F\u002Fdblp.org\u002Frec\u002Fbib\u002Fconf\u002Feics\u002FShahFD19},\n  bibsource = {dblp 计算机科学文献数据库，https:\u002F\u002Fdblp.org}\n}\n```\n\n## 贡献\n\n我们非常欢迎您的贡献、反馈、问题和功能请求！请 [提交 GitHub 问题](https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Ftensorwatch\u002Fissues\u002Fnew) 或发送拉取请求。请阅读 [微软行为准则](https:\u002F\u002Fopensource.microsoft.com\u002Fcodeofconduct\u002F) 并参阅 [贡献说明](https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Ftensorwatch\u002Fblob\u002Fmaster\u002FCONTRIBUTING.md)。\n\n## 联系方式\n\n加入 [Facebook](https:\u002F\u002Fwww.facebook.com\u002Fgroups\u002F378075159472803\u002F) 上的 TensorWatch 群组，以获取最新动态或提出任何问题。\n\n## 致谢\n\nTensorWatch 利用多个开源库实现其众多功能。其中包括：[hiddenlayer](https:\u002F\u002Fgithub.com\u002Fwaleedka\u002Fhiddenlayer)、[torchstat](https:\u002F\u002Fgithub.com\u002FSwall0w\u002Ftorchstat)、[Visual-Attribution](https:\u002F\u002Fgithub.com\u002Fyulongwang12\u002Fvisual-attribution)、[pyzmq](https:\u002F\u002Fgithub.com\u002Fzeromq\u002Fpyzmq)、[receptivefield](https:\u002F\u002Fgithub.com\u002Ffornaxai\u002Freceptivefield)、[nbformat](https:\u002F\u002Fgithub.com\u002Fjupyter\u002Fnbformat)。最新列表请参阅 [setup.py](setup.py) 中的 `install_requires` 部分。\n\n## 许可证\n\n本项目采用 MIT 许可证发布。更多详情请参阅 [许可证文件](LICENSE.txt)。","# TensorWatch 快速上手指南\n\nTensorWatch 是由微软研究院开发的调试与可视化工具，专为数据科学、深度学习和强化学习设计。它能在 Jupyter Notebook 中实时展示机器学习训练过程，并支持自定义仪表盘和“懒日志”（Lazy Logging）模式，无需预先记录即可对运行中的模型进行任意查询。\n\n## 环境准备\n\n*   **操作系统**：支持 Windows, macOS, Linux。\n*   **Python 版本**：Python 3.x。\n*   **深度学习框架**：\n    *   PyTorch 0.4 - 1.x（主要测试环境）。\n    *   TensorFlow Eager Tensors（大多数功能兼容）。\n*   **前置依赖**：\n    *   **Graphviz**：用于绘制网络结构图。部分平台需手动安装。\n        *   Ubuntu\u002FDebian: `sudo apt-get install graphviz`\n        *   macOS (Homebrew): `brew install graphviz`\n        *   Windows: 下载安装包或使用 `choco install graphviz`。\n    *   **Jupyter Notebook**：用于查看实时可视化图表。\n\n## 安装步骤\n\n推荐使用国内镜像源加速安装（如清华源或阿里源）。\n\n```bash\npip install tensorwatch -i https:\u002F\u002Fpypi.tuna.tsinghua.edu.cn\u002Fsimple\n```\n\n> **⚠️ 安全提示**：TensorWatch 是开发调试工具，**严禁**在生产环境、多租户环境或不可信网络中使用。默认情况下它绑定在本地回环地址 (`127.0.0.1`)，请勿将其暴露给外部网络，以防任意代码执行风险。\n\n## 基本使用\n\n以下示例演示如何每秒记录一个整数及其平方，并在 Jupyter Notebook 中实时查看折线图。\n\n### 1. 编写记录脚本\n\n创建 `log_script.py`，运行后将生成日志文件 `test.log` 和可视化笔记本 `test.ipynb`。\n\n```python\nimport tensorwatch as tw\nimport time\n\n# 初始化 Watcher，数据将存储在 test.log 文件中\nw = tw.Watcher(filename='test.log')\n\n# 创建一个名为 'metric1' 的数据流\ns = w.create_stream(name='metric1')\n\n# 生成用于查看实时数据的 Jupyter Notebook 文件\nw.make_notebook()\n\nfor i in range(1000):\n    # 写入 (x, y) 元组数据\n    s.write((i, i*i))\n    time.sleep(1)\n```\n\n### 2. 查看实时可视化\n\n1.  运行上述脚本后，当前目录下会生成 `test.ipynb`。\n2.  在终端启动 Jupyter Notebook：\n    ```bash\n    jupyter notebook\n    ```\n3.  在浏览器中打开 `test.ipynb`。\n4.  点击菜单栏的 **Cell > Run all**。\n5.  你将看到实时的折线图，随着脚本不断写入新数据，图表会动态更新。\n\n### 核心原理简述\nTensorWatch 将数据同时写入文件和 TCP\u002FIP Socket。Jupyter Notebook 首先加载历史文件数据，然后监听 Socket 接收新数据流，从而实现“文件回放 + 实时推送”的双重可视化机制。","某算法工程师正在 Jupyter Notebook 中调试一个复杂的 PyTorch 强化学习模型，训练过程中损失函数波动异常，急需定位梯度消失或数据分布偏移的根源。\n\n### 没有 tensorwatch 时\n- 只能依赖传统的静态日志打印，无法实时观察训练动态，往往要等 epoch 结束后才能发现模型早已发散。\n- 排查内部张量状态需手动插入大量 `print` 语句并重启训练，打断开发心流且难以复现瞬时错误。\n- 缺乏直观的网络结构视图，面对深层嵌套的自定义模块，难以快速确认数据流向是否符合预期。\n- 想要分析特定中间层的统计特征时，必须预先硬编码记录逻辑，无法在训练中途灵活发起临时查询。\n\n### 使用 tensorwatch 后\n- 利用实时可视化仪表盘，直接在 Notebook 中监控损失曲线与梯度直方图，秒级发现训练异常并立即干预。\n- 通过“懒日志模式”（Lazy Logging），无需修改代码或重启进程，即可向运行中的训练发送任意 Python 表达式查询即时状态。\n- 一键生成清晰的计算图拓扑结构，自动解析模型层级关系，快速验证网络架构设计的正确性。\n- 支持自定义扩展 Dashboard，将关键指标流式聚合展示，把原本分散的调试信息整合为统一的决策视图。\n\ntensorwatch 将原本割裂、滞后的离线调试转变为交互式、实时的在线诊断，极大缩短了从“发现异常”到“定位问题”的闭环时间。","https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fmicrosoft_tensorwatch_73bfde95.gif","microsoft","Microsoft","https:\u002F\u002Foss.gittoolsai.com\u002Favatars\u002Fmicrosoft_4900709c.png","Open source projects and samples from Microsoft",null,"opensource@microsoft.com","OpenAtMicrosoft","https:\u002F\u002Fopensource.microsoft.com","https:\u002F\u002Fgithub.com\u002Fmicrosoft",[85,89,93],{"name":86,"color":87,"percentage":88},"Jupyter Notebook","#DA5B0B",90.3,{"name":90,"color":91,"percentage":92},"Python","#3572A5",9.7,{"name":94,"color":95,"percentage":96},"Batchfile","#C1F12E",0,3466,359,"2026-04-04T09:24:40","MIT","未说明",{"notes":103,"python":104,"dependencies":105},"该工具主要用于 Jupyter Notebook 环境进行调试和可视化。需手动安装 Graphviz 以生成网络图。安全警告：该工具设计用于开发调试，非生产环境；默认绑定本地回环地址 (127.0.0.1)，支持通过 ZeroMQ 进行任意代码查询（Lazy Logging 模式），多进程使用时需配置共享 HMAC 密钥以确保安全。","3.x",[106,107,108],"PyTorch (0.4-1.x)","TensorFlow (支持 Eager Tensors)","graphviz",[13,15,51,14,54],[111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128],"ai","deep-learning","deeplearning","machine-learning","machinelearning","reinforcement-learning","debugging","debugging-tool","debug","monitoring","explainable-ai","explainable-ml","saliency","model-visualization","data-science","python","jupyter-notebook","jupyter","2026-03-27T02:49:30.150509","2026-04-06T05:14:57.327227",[132,137,142,147,152],{"id":133,"question_zh":134,"answer_zh":135,"source_url":136},10038,"在 Windows 上运行 draw_model 时出现 'AttributeError: Dot object has no attribute _repr_svg_' 错误怎么办？","该问题通常是因为 Graphviz 未正确安装或配置。请执行以下步骤：\n1. 不要仅使用 conda install graphviz，需前往 https:\u002F\u002Fgraphviz.gitlab.io\u002F_pages\u002FDownload\u002FDownload_windows.html 下载并安装 Graphviz 2.38 的 MSI 文件。\n2. 将 Graphviz 的 bin 目录路径添加到系统环境变量 PATH 中。\n3. 找到 Python 环境中的 pydot.py 文件，将其中的 self.prog = 'dot' 修改为 self.prog = 'dot.exe'。\n完成上述步骤后重启内核即可解决。","https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Ftensorwatch\u002Fissues\u002F50",{"id":138,"question_zh":139,"answer_zh":140,"source_url":141},10039,"使用 pip install tensorwatch 安装失败，提示依赖包未在 PyPI 托管（depends on package not hosted on PyPi）如何解决？","这是由于特定版本（如 0.9.0）依赖了 GitHub 上的 pydot 分支导致的。解决方法有两种：\n1. 升级安装：维护者已修复此问题，尝试运行 pip install tensorwatch --upgrade 安装最新版本。\n2. 源码安装：如果升级无效，可以克隆源码手动安装：\n   git clone \u003Crepo_url>\n   cd tensorwatch\n   python setup.py build\n   python setup.py install\n或者暂时回退到不受影响的版本（如 0.8.10）。","https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Ftensorwatch\u002Fissues\u002F57",{"id":143,"question_zh":144,"answer_zh":145,"source_url":146},10040,"pip 安装时报错 'SyntaxError: invalid syntax' 且指向 receptivefield 包，原因是什么？","这是因为您使用的 Python 版本过低（如 Python 3.5），而依赖包 receptivefield 需要 Python 3.6 及以上版本才能运行（使用了 f-string 语法）。\n解决方案：\n1. 强烈建议将环境升级到 Python 3.6 或更高版本。\n2. 维护者已暂时移除了该依赖，如果是旧版报错，尝试升级 tensorwatch 可能也能解决。","https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Ftensorwatch\u002Fissues\u002F11",{"id":148,"question_zh":149,"answer_zh":150,"source_url":151},10041,"在 Colab 或本地运行时出现 'FileNotFoundError: No such file or directory: ...\u002Fimagenet_class_index.json' 错误怎么办？","这是因为 pip 安装包中遗漏了必要的 JSON 数据文件。\n解决方案：\n1. 升级 tensorwatch 包：运行 pip install tensorwatch --upgrade，维护者已在后续版本中通过修改 setup.py 包含了该文件。\n2. 如果是在 Colab 中且无法立即升级，可以临时通过 git clone 仓库获取缺失文件，或者手动下载 imagenet_class_index.json 放到报错提示的目录下。","https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Ftensorwatch\u002Fissues\u002F9",{"id":153,"question_zh":154,"answer_zh":155,"source_url":156},10042,"导出 ONNX 模型时报错 'RuntimeError: Failed to export an ONNX attribute, since it's not constant' 是什么原因？","这不是 tensorwatch 的代码 bug，而是 ONNX 本身的限制。ONNX 不支持动态属性（例如动态的 kernel size）。\n解决方案：\n检查您的自定义模型代码，确保所有用于导出的参数（如卷积核大小、步长等）都是静态常量，而不是在运行时计算的变量。如果模型中包含动态计算图结构，可能需要重构模型以支持静态导出。","https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Ftensorwatch\u002Fissues\u002F20",[158,161,164,167,170,173,176],{"id":159,"version":160,"summary_zh":79,"released_at":79},107256,"v0.9.0",{"id":162,"version":163,"summary_zh":79,"released_at":79},107257,"v0.8.10",{"id":165,"version":166,"summary_zh":79,"released_at":79},107258,"v0.8.8",{"id":168,"version":169,"summary_zh":79,"released_at":79},107259,"v0.8.3",{"id":171,"version":172,"summary_zh":79,"released_at":79},107260,"v0.8.2",{"id":174,"version":175,"summary_zh":79,"released_at":79},107261,"v0.8.1",{"id":177,"version":178,"summary_zh":79,"released_at":79},107262,"v0.8.0"]