Skip to content

feat: add BatchNormalization layer to TensorMap model builder#322

Open
Sickwoman wants to merge 1 commit intoc2siorg:mainfrom
Sickwoman:feature/add-batchnorm-layer-clean
Open

feat: add BatchNormalization layer to TensorMap model builder#322
Sickwoman wants to merge 1 commit intoc2siorg:mainfrom
Sickwoman:feature/add-batchnorm-layer-clean

Conversation

@Sickwoman
Copy link
Copy Markdown
Contributor

Summary

Adds full-stack support for the BatchNormalization layer in TensorMap,
allowing users to add batch normalization between layers in the model builder canvas.

Changes

Backend

  • app/services/model_generation.py — Added custombatchnorm node handler:
elif node_type == "custombatchnorm":
    return tf.keras.layers.BatchNormalization(
        momentum=float(params.get("momentum", 0.99)),
        epsilon=float(params.get("epsilon", 0.001)),
        name=name,
    )(input_tensor)
  • tests/test_model_generation.py — Added unit tests for BatchNormalization layer

Frontend

  • Canvas.jsx — Registered custombatchnorm node type with default params { momentum: "0.99", epsilon: "0.001" }
  • Helpers.jsx — Added validation for custombatchnorm node (momentum and epsilon required)
  • Sidebar.jsx — Added BatchNorm drag-and-drop item to the layer sidebar
  • BatchNormalizationNode/ — New custom node component with momentum and epsilon input fields

Parameters

Parameter Default Description
momentum 0.99 Momentum for the moving average
epsilon 0.001 Small float added to variance to avoid division by zero

How to Test

  1. Open the model builder canvas
  2. Drag BatchNorm from the sidebar into the canvas
  3. Connect it between two layers (e.g. Dense → BatchNorm → Dense)
  4. Set momentum and epsilon values
  5. Validate and train the model

No Breaking Changes

All existing layer types and model builder functionality are unchanged.

- Add BatchNormalizationNode component with momentum and epsilon params
- Register custombatchnorm in Canvas nodeTypes and defaultParams
- Add BatchNorm properties panel to NodePropertiesPanel
- Add BatchNorm entry to Sidebar layer list
- Add node-batchnorm color token to tailwind.config.js
@Sickwoman
Copy link
Copy Markdown
Contributor Author

Reopened PR#252 as suggested.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants