deep learning neural network architectures, Neuralnet diagram#7795
deep learning neural network architectures, Neuralnet diagram#7795seongwoochikin-dev wants to merge 23 commits into
Conversation
Adds a new `neuralnet` diagram type supporting sequential and graph modes. - Sequential mode: layers auto-wired top-to-bottom - Graph mode: named nodes with explicit edges and skip connections - Tensor shape auto-computation on sequential networks - 22 layer types: Dense, Conv2D, LSTM, BatchNorm, Attention, etc. - Color-coded SVG rendering by layer category - Langium grammar, DB, renderer, styles, and unit tests Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…geset - Add neuralnet to langium-config.json so NeuralnetGrammarGeneratedModule is generated during build (fixes Netlify/CI failure) - Add changeset for minor version bump (mermaid + @mermaid-js/parser) - Add docs page at syntax/neuralnet.md with sequential/graph examples Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Lowercase activation names (relu, softmax, tanh) were tokenized as NN_ID with higher priority than NN_PARAM_VAL. Accepting all three token types in NeuralParam fixes parsing of Conv2D[32, 3x3, relu] style params. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Add CommonValueConverter to module.ts so TITLE tokens are stripped of the 'title ' prefix (fixes title test) - Fix typo @mermapnid-js/parser → @mermaid-js/parser in neuralnetParser.ts - Add 4 explicit targeted test cases covering all targeted parse scenarios - Add 'neuralnet' to cspell dictionary - All 13 unit tests now pass Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Conv, conv, GELU, LSTM, relu, Softmax, softmax, Autoencoder — all used in neuralnet diagram files and docs. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Neuron mode: - New 'neuron' keyword: `neuralnet sequential neuron` - Each layer rendered as a column of circles with all-to-all connections - Automatic truncation when neurons > 8: shows first 3, ⋮, last 2 - Color-coded circles by layer category (green=input, blue=dense, etc.) Block mode fixes: - Apply fill/stroke/text colors via D3 attributes directly (not CSS) so rendering works without CSS injection pipeline - Fix SVG height: use configureSvgSize(..., false) for explicit height so tall sequential diagrams aren't clipped to one visible row - Add fill/stroke/stroke-width to edge paths Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Feature/neuralnet
feat(neuralnet): 신경망 다이어그램 렌더러 추가
🦋 Changeset detectedLatest commit: 4ce44a7 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
✅ Deploy Preview for mermaid-js ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
…e.ts Duplicate import of CommonValueConverter (from both valueConverter.js and common/index.js) caused TS2300 error, preventing parser type declarations from being generated and breaking the Netlify build. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@mermaid-js/examples
mermaid
@mermaid-js/layout-elk
@mermaid-js/layout-tidy-tree
@mermaid-js/mermaid-zenuml
@mermaid-js/parser
@mermaid-js/tiny
commit: |
ESLint uses parserOptions.project, so all linted files must be included in a tsconfig. neuralnet.spec.js was not matched by the previous '**/*.ts' glob, causing the lint job to fail. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Argos notifications ↗︎
|
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## develop #7795 +/- ##
==========================================
- Coverage 3.27% 2.87% -0.40%
==========================================
Files 599 679 +80
Lines 60986 73122 +12136
Branches 921 1011 +90
==========================================
+ Hits 1997 2102 +105
- Misses 58989 71020 +12031
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
Add direct DB method tests, detector tests, and neuron render style tests. Coverage improves for neuralnetDb.ts, neuralnetDetector.ts, and neuralnetParser.ts (neuron keyword path). Tests: 13 → 26 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…press
tsconfig.json excludes 'cypress' (added in a prior fix to suppress tsc
errors). tsconfig.eslint.json extends tsconfig.json and inherits that
exclude, blocking ESLint from linting cypress/**/*.{ts,js} files.
Override the exclude list in tsconfig.eslint.json so cypress is
included for linting while still excluded from the production tsc build.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Chevrotain uses first-match semantics by default. NN_WORD terminal was defined before TITLE/ACC_DESCR/ACC_TITLE (imported from common), so 'title My CNN' was tokenized as NN_WORD instead of TITLE, causing Cypress E2E tests to fail with a parser error. Add NeuralnetTokenBuilder that sets LONGER_ALT on NN_WORD so that common directive terminals (TITLE, ACC_DESCR, ACC_TITLE) are preferred when they match a longer string at the same position. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Hi @seongwoochikin-dev — thanks for putting this together, and for going the distance with grammar, renderer, styles, docs, tests, and a changeset all in one pass. That's a lot of work, and it's clear you care about the ML visualisation use case. Before we dig into a code review, I'd like to raise a higher-level design question that I think is worth resolving first — because the answer changes what the right shape of this contribution is. Is this a new diagram type, or is it a flowchart preset? Looking at the Argos previews, both modes are essentially boxes-and-arrows:
I can almost certainly reproduce the block-mode screenshots today with stock Where the PR does add something genuinely new is:
Everything else — 700-line renderer with hardcoded The concerns this raises for me:
What I'd be enthusiastic about instead (any one of these alone would be a great PR):
None of this is a "no" — it's a request to talk about the shape of the contribution before we ask you to polish a renderer, parser, and grammar that I'm worried we'll have to maintain in parallel forever. The tensor-shape propagation in particular feels like something Mermaid genuinely lacks, and I'd love to see that land. Would you be open to exploring option (2) — keeping your sugar syntax and shape-propagation but routing through the flowchart renderer? I'm happy to point at the relevant entry points and pair on the design if that's useful. Either way — thank you again for the contribution and the care you've taken. The neuron view is genuinely delightful. |
Previously the renderer hardcoded category colours (e.g. '#82c46e') as
inline SVG attributes, so the diagram ignored the active theme and had
no dark-mode variant — the nn*Fill style options were defined but never
used by the renderer.
- Add getNeuralnetPalette(darkMode) in theme-helpers.js
- Register nn*Fill / nn*Stroke / nnTextColor / nnEdgeColor / nnLabelTextColor
theme variables in theme-default.js and theme-dark.js
- Renderer now resolves colours via resolveCategoryColors() reading
getConfig().themeVariables, with the built-in palette as fallback only
- Both block and neuron modes follow the active theme and honour per-category
user overrides (themeVariables: { nnConvFill: '#...' })
- Remove the two hardcoded colour tables (CATEGORY_COLORS, NEURON_FILL)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Thanks so much for the thoughtful review — this is exactly the kind of design conversation I was hoping for, and you've clearly engaged deeply with the actual output rather than just the diff. You're right on the most important technical point, and I've fixed it. Let me address the concerns concretely and then make the case for where I'd like to land. ✅ Theme support — fixed (you were right) Added getNeuralnetPalette(darkMode) in theme-helpers.js
Layer-type catalogue churn is also addressed: unknown layer types already fall through to the structural category rather than erroring, so a Mamba or MoE block renders today without a grammar change. I'm happy to document that explicitly. 🎯 Where I'd love to keep the dedicated diagram The two things you flagged as genuinely new (sequential auto-wiring + tensor-shape propagation) are exactly why a flowchart preset doesn't get us there. Shape propagation isn't styling — it's a forward pass over the graph: Conv2D[6,5x5] on (28,28,1) has to compute (24,24,6), which needs the layer semantics (kernel, stride, pooling factor). That logic has to live somewhere stateful that understands layers. Once we have a layer-aware DB and a shape-propagation pass, emitting flowchart text underneath is an implementation detail — and it's one I'm genuinely torn on, because: The neuron view is not expressible as a flowchart. A Dense[128] → Dense[64] pair is 8,192 edges; the value is precisely the truncation convention (1,2,3,⋮,127,128) and the all-to-all visual. There's no classDef that produces this. So at minimum the diagram needs its own renderer for neuron mode — which means the "just desugar to flowchart" path still leaves us maintaining a bespoke renderer for half the feature.
A concrete proposal Keep the layer-aware DB + shape-propagation pass (the domain logic you said Mermaid lacks) — this is the irreducible core. Would that split work for you? If so, I'll refactor block mode onto the shared pipeline in a follow-up commit on this PR. And thank you again — the push on theme variables already made this materially better. |
|
Hi @seongwoochikin-dev, |






🚀 Feature: Add
neuralnetdiagram type for deep-learning architecture visualisationAdds a new
neuralnetdiagram type for visualising deep learning neural network architectures.💡 Diagram Examples
1. Sequential (auto-wired):
2. Graph (skip connections):
3. Neuron view:
📑 Summary
neuralnetkeyword with layout modes (sequential/graph) and an optionalneuronrendering mode.Dense,Conv1D/2D/3D,MaxPool1D/2D,AvgPool1D/2D,LSTM,GRU,RNN,Flatten,Reshape,BatchNorm,Dropout,Embedding,Attention,MultiHeadAttention,Add,Concatenate,Input,Output.1, 2, 3, ⋮, n-1, n).darkModecompatibility usingthemeVariables(no hard-coded hex values).📏 Design Decisions
-->edges.NN_WORD): Unifies node IDs and parameter values into one terminal to avoid lexer priority conflicts between IDs and activation names (likerelu).(28,28,1) → (24,24,6)).MAX_SHOW = 8to neatly display large layers.📂 Files Changed
🧪 Testing
parser/neuralnet.spec.tscypress/integration/rendering/neuralnet.spec.ts📋 Tasks
MERMAID_RELEASE_VERSIONis used for all new features).pnpm changeset(Changeset messages prefixed withfeat:).