一键导入
draw-neural-networks-typst
Empower the agent to generate high-quality Neural Network architecture diagrams in Typst using the neural-netz package.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Empower the agent to generate high-quality Neural Network architecture diagrams in Typst using the neural-netz package.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
| name | draw-neural-networks-typst |
| description | Empower the agent to generate high-quality Neural Network architecture diagrams in Typst using the neural-netz package. |
Empower the agent to generate high-quality Neural Network architecture diagrams in Typst using the neural-netz package.
Whenever the user requests drawing or visualizing a neural network in Typst, always start by importing the main function from the neural-netz package:
#import "@preview/neural-netz:0.3.0": draw-network
draw-network)The core function is draw-network. It accepts the following parameters:
#draw-network(
layers, // (Array) Required. List of dictionaries defining the layers
connections: (), // (Array) Optional. List of non-linear connections (skip connections)
palette: "warm", // (String) Optional. Color palette: "warm" (default) or "cold"
show-legend: false, // (Boolean) Optional. If true, displays the chart legend
legend-title: "Layers", // (String) Optional. Title for the legend
scale: 100%, // (Relative) Optional. Overall scale of the drawing (e.g., 50% to fit the page)
stroke-thickness: 1, // (Float) Optional. Line thickness
depth-multiplier: 0.3, // (Float) Optional. Multiplier for 3D visual depth
show-relu: false // (Boolean) Optional. If true, draws a darker color on convolutions to indicate ReLU
)
layers)The main parameter of draw-network is an array of dictionaries. The order in the array defines the sequential order (from left to right), and they are connected automatically by default.
type)"input": Input layer (can take the key image: "path.jpg" or image: none)."conv": Convolution."pool": Pooling. By default, it sticks to the previous layer."convres": Residual Convolution."fc": Fully Connected (Usually 2D, set depth: 0)."custom": Fully customizable layer (using fill, bandfill, opacity).type: The type of the layer (described above).offset: Space/distance from the previous layer (e.g., offset: 2).widths: Array of widths for layer subdivisions (e.g., (1, 1) or (1, 2)).height and depth: Height and depth (e.g., height: 6, depth: 8). For pure 2D, set depth: 0.channels: Array with labels for the channels that appear on the axes (e.g., (32, 64, 128) or ("10",)).label: Name/Text displayed below the block.connection-label: Name displayed on the arrow connecting to the NEXT layer.name: Unique identifier used to create manual connections (e.g., name: "conv1").show-connection: (Boolean) Whether the automatic arrow/connection after this layer should be drawn.connections)Used for skip-connections (like in ResNets or U-Nets).
Each connection is a dictionary in the connections array:
from: Name of the origin layer (defined in the name attribute of the layer).to: Name of the destination layer.type: Usually "skip".mode: Connection style. Options: "depth", "flat", or "air".label: Text label over the connection.pos: Vertical/horizontal offset of the connection arc (e.g., pos: 5).touch-layer: (Boolean) If true and mode: "air", the arrow touches the layer instead of ending with a loose arrowhead.Use this example as a baseline to understand the assembly:
#import "@preview/neural-netz:0.3.0": draw-network
#draw-network((
// Input
(type: "input", label: "Image", name: "in", show-connection: true),
// Convolutional Block
(type: "conv", widths: (1.5, 1.5), height: 4, depth: 4, label: "Conv1", name: "c1", offset: 2),
(type: "pool", channels: ("64",), height: 2, depth: 2, connection-label: "Max Pool"),
// Block that does not propagate arrow automatically
(type: "convres", channels: (128, 256), height: 5, depth: 5, label: "ResBlock", name: "c2", offset: 3, show-connection: false),
// Linear / Fully Connected 2D Layer (depth: 0)
(type: "fc", channels: ("10",), height: 6, depth: 0, label: "Linear", name: "out", offset: 2)
),
// Extra connections (skip connections)
connections: (
(from: "in", to: "c2", type: "skip", mode: "air", label: "Skip Connection", pos: 6, touch-layer: true),
),
// Global customizations
palette: "warm",
show-legend: true,
legend-title: "Architecture",
show-relu: true
)
height/depth proportions according to Spatial Resolution or Channels).scale parameter (e.g., scale: 75%).type: "custom" with fill: rgb("#...")), otherwise, encourage the use of native palettes (warm or cold).depth: 0 for purely Dense/Fully Connected layers to highlight the difference between 3D tensors and 1D vectors.