PlotNeuralNet
PlotNeuralNet is a Python package for generating high-quality neural network architecture diagrams using predefined or custom layer templates, seamlessly integrating Python and LaTeX. It includes pre-built resources for popular architectures like AlexNet and FCN, making it ideal for research papers and presentations.
Install / Use
/learn @kgruiz/PlotNeuralNetREADME
PlotNeuralNet
PlotNeuralNet is a Python package that provides tools to generate high-quality neural network architecture diagrams for research papers, presentations, and reports. It leverages LaTeX and Python for seamless integration into scientific workflows.
This package is based on the original PlotNeuralNet by HarisIqbal88, with improvements for better usability and a modular package structure.
Features
- Programmatically generate neural network diagrams using Python.
- Predefined layer types (e.g., Conv, Pool, SoftMax).
- Easily extendable for custom layer shapes.
- Pre-built LaTeX templates for popular architectures like AlexNet, FCN, and HED.
- Fully structured as a Python package for streamlined integration into projects.
Getting Started
Installation
-
Clone the repository:
git clone https://github.com/<your-username>/PlotNeuralNet.git cd PlotNeuralNet -
Install the package:
pip install . -
Verify the installation:
import PlotNeuralNet print("PlotNeuralNet installed successfully!")
Usage
The package is organized to simplify the creation of diagrams. It includes Python modules (pycore and pyexamples) and LaTeX resources (layers).
1. Python Usage
Define an Architecture
You can use the Python API to define your architecture programmatically. For example:
from PlotNeuralNet.pycore import tikzeng
from PlotNeuralNet.pycore.blocks import block_2ConvPool, block_Unconv
# Define architecture
arch = [
tikzeng.to_head('..'),
tikzeng.to_cor(),
tikzeng.to_begin(),
# Input image
tikzeng.to_input('../examples/fcn8s/cats.jpg'),
# Encoder
*block_2ConvPool(name='b1', botton='input', top='b2', s_filer=256, n_filer=64),
*block_2ConvPool(name='b2', botton='b2', top='b3', s_filer=128, n_filer=128),
# Decoder
*block_Unconv(name='b4', botton='b3', top='output', s_filer=64, n_filer=32),
# Output layer
tikzeng.to_ConvSoftMax(name='softmax', offset="(1,0,0)", to="(output-east)", width=1, height=30, depth=30),
tikzeng.to_end(),
]
# Generate the architecture diagram
def main():
tikzeng.to_generate(arch, "my_architecture.tex")
if __name__ == "__main__":
main()
Compile and View the Diagram
Run the Python script:
python my_architecture.py
Compile the .tex file with:
bash ../tikzmake.sh my_architecture
2. LaTeX Usage
You can directly modify .tex files in the examples directory, such as examples/FCN-8 or examples/HED. Each .tex file demonstrates how to use LaTeX for defining architectures.
To compile a .tex file, use:
pdflatex <file>.tex
3. Access Predefined Resources
The package structure includes predefined resources for easy reuse:
LaTeX Resources
- Available in the
PlotNeuralNet/layers/directory. - Example LaTeX layer definitions:
\input{layers/Box.sty}
Examples
- Predefined architectures like FCN, HED, AlexNet are in
PlotNeuralNet/examples/. - Modify these examples to fit your use case.
Python Scripts
- Python examples for generating diagrams programmatically are in
PlotNeuralNet/pyexamples/. - Example usage:
python PlotNeuralNet/pyexamples/unet.py
Package Structure
The package is organized as follows:
PlotNeuralNet/
├── LICENSE # License file
├── MANIFEST.in # File inclusion rules
├── README.md # Documentation
├── setup.py # Installation script
├── PlotNeuralNet/ # Main package directory
│ ├── __init__.py # Package initializer
│ ├── pycore/ # Core Python modules
│ ├── layers/ # LaTeX resources
│ ├── examples/ # Predefined architectures in LaTeX
│ ├── pyexamples/ # Python examples
├── dist/ # Build artifacts (after running setup.py)
├── build/ # Temporary build files
Advanced Features
-
Custom Layers
- Extend
pycore.blocksor create your own block definitions to support custom layers.
- Extend
-
Batch Processing
- Use Python scripts to generate multiple architectures programmatically.
-
Predefined Functions
block_2ConvPoolandblock_Unconvsimplify common layer patterns.
Acknowledgments
This package is based on the original PlotNeuralNet by HarisIqbal88 and licensed under the MIT License.
License
This project is licensed under the MIT License. See the LICENSE file for more details.
Related Skills
claude-opus-4-5-migration
107.6kMigrate prompts and code from Claude Sonnet 4.0, Sonnet 4.5, or Opus 4.1 to Opus 4.5
model-usage
346.8kUse CodexBar CLI local cost usage to summarize per-model usage for Codex or Claude, including the current (most recent) model or a full model breakdown. Trigger when asked for model-level usage/cost data from codexbar, or when you need a scriptable per-model summary from codexbar cost JSON.
TrendRadar
50.7k⭐AI-driven public opinion & trend monitor with multi-platform aggregation, RSS, and smart alerts.🎯 告别信息过载,你的 AI 舆情监控助手与热点筛选工具!聚合多平台热点 + RSS 订阅,支持关键词精准筛选。AI 智能筛选新闻 + AI 翻译 + AI 分析简报直推手机,也支持接入 MCP 架构,赋能 AI 自然语言对话分析、情感洞察与趋势预测等。支持 Docker ,数据本地/云端自持。集成微信/飞书/钉钉/Telegram/邮件/ntfy/bark/slack 等渠道智能推送。
mcp-for-beginners
15.8kThis open-source curriculum introduces the fundamentals of Model Context Protocol (MCP) through real-world, cross-language examples in .NET, Java, TypeScript, JavaScript, Rust and Python. Designed for developers, it focuses on practical techniques for building modular, scalable, and secure AI workflows from session setup to service orchestration.
