gnn-code-generation
GNN code generation for simulation frameworks. Use when generating PyMDP, RxInfer.jl, ActiveInference.jl, JAX, DisCoPy, PyTorch, NumPyro, Stan, or bnlearn…
от ActiveInferenceInstitute★ 36 звёзд на GitHub
Установить gnn-code-generation в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Об этом скилле
GNN Code Generation / Render (Step 11)
Purpose
Generates executable simulation code from parsed GNN models targeting multiple Active Inference frameworks. Performs pre-render validation of POMDP structures and matrix normalization.
Key Commands
# Render code for all frameworks
python src/gnn/11_render.py --target-dir input/gnn_files --output-dir output --verbose
# As part of pipeline
python src/gnn/main.py --only-steps 11 --verbose
Supported Frameworks
| Framework | Language | Subdirectory | Output |
|---|---|---|---|
| PyMDP | Python | render/pymdp/ |
.py scripts |
| RxInfer.jl | Julia | render/rxinfer/ |
.jl scripts |
| ActiveInference.jl | Julia | render/activeinference_jl/ |
.jl scripts |
| JAX | Python | render/jax/ |
.py scripts |
| DisCoPy | Python | render/discopy/ |
.py scripts |
| PyTorch | Python | render/pytorch/ |
.py scripts |
| NumPyro | Python | render/numpyro/ |
.py scripts |
| Stan | Stan | render/stan/ |
.stan models |
| bnlearn | Python | generator-backed | .py scripts |
API
from gnn.render import (
process_render,
render_gnn_spec,
get_supported_frameworks,
validate_render,
PyMDPRenderer,
JAXRenderer,
)
# Render for all frameworks (used by pipeline)
process_render(target_dir, output_dir, verbose=True)
# Render a single GNN spec (positional target + output dir)
result = render_gnn_spec(parsed_spec, "pymdp", "output/11_render_output/pymdp")
# Query supported frameworks
frameworks = get_supported_frameworks() # ['pymdp', 'rxinfer', ..., 'stan', 'bnlearn']
# Validate render output
validate_render(result, framework="pymdp")
Key Exports
process_render/render_gnn_spec— core rendering functionsPyMDPRenderer/JAXRenderer— renderer classesget_supported_frameworks/validate_render— utilities
POMDP Processing Pipeline
The render processor follows a structured pipeline for each GNN file:
- POMDP Extraction — extracts state spaces (A, B, C, D matrices) from GNN specs
- Validation — validates dimensional consistency and completeness
- Matrix Normalization — ensures A-matrix columns and B-matrix transition rows sum to 1.0
- Framework Code Generation — generates framework-specific executable code
- Documentation — creates structured overview of rendering results
Dependencies
# Core rendering (no extra deps needed)
uv sync
# For Julia frameworks (RxInfer.jl, ActiveInference.jl)
# Requires Julia installed and packages available in the active Julia environment
julia --startup-file=no -e 'using RxInfer, ActiveInference, JSON, Distributions, StatsBase'
# For DisCoPy
uv sync --extra graphs
Output
- Generated scripts in
output/11_render_output/ - Per-framework subdirectories:
pymdp/,rxinfer/,activeinference_jl/,jax/,discopy/,pytorch/,numpyro/,stan/,bnlearn/ - One script per model per framework
- Render overview documentation
Troubleshooting
| Issue | Solution |
|---|---|
| Empty render output | Check GNN file has valid StateSpaceBlock section |
| Matrix normalization warnings | Verify matrix dimensions match connections |
| Julia framework errors | Ensure Julia is installed and packages available |
MCP Tools
This module registers tools with the GNN MCP server (see mcp.py):
get_render_module_infolist_render_frameworksprocess_renderrender_gnn_to_formatrender_spec_to_format
References
Documentation
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
- AGENTS.md
- README.md
- SPEC.md
- __init__.py
- activeinference_jl/AGENTS.md
- activeinference_jl/README.md
- activeinference_jl/SPEC.md
- activeinference_jl/__init__.py
- activeinference_jl/activeinference_renderer.py
- admission.py
- bnlearn/AGENTS.md
- bnlearn/README.md
- bnlearn/SPEC.md
- bnlearn/__init__.py
- bnlearn/bnlearn_renderer.py
- bnlearn/source_program.py
- continuous_common.py
- continuous_script.py
- contracts.py
- cpomdp/AGENTS.md
- cpomdp/README.md
- cpomdp/SPEC.md
- cpomdp/__init__.py
- cpomdp/admission.py
- cpomdp/cpomdp_renderer.py
- cpomdp/finite_controls.py
- cpomdp/script_template.py
- discopy/AGENTS.md
- discopy/README.md
- discopy/SPEC.md
- discopy/__init__.py
- discopy/bootstrap.py
- discopy/code_templates.py
- discopy/diagram_builders.py
- discopy/discopy_renderer.py
- discopy/file_translation.py
- discopy/gnn_parsing.py
- discopy/matrix_builders.py
- discopy/symmetry.py
- discopy/translator.py
FAQ
Что делает скилл gnn-code-generation?
GNN code generation for simulation frameworks. Use when generating PyMDP, RxInfer.jl, ActiveInference.jl, JAX, DisCoPy, PyTorch, NumPyro, Stan, or bnlearn code from GNN model specifications.
Как установить скилл gnn-code-generation?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл gnn-code-generation запускает скрипты?
Да, скилл несёт исполняемые скрипты. Проверь исходник перед установкой.
Похожие скиллы
mcp-builder
AnthropicGuide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
claude-api
AnthropicReference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
algorithmic-art
AnthropicCreating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
mcp-integration
AnthropicThis skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…