BatchNorm Shape Calculator

Verify your PyTorch BatchNorm2d configuration. BatchNorm preserves the input shape but requires num_features to match the channel dimension. Check your setup instantly.

Built by Michael Lip

Frequently Asked Questions

Does BatchNorm change the tensor shape?

No. BatchNorm2d preserves the input shape exactly. If input is [batch, C, H, W], output is [batch, C, H, W]. However, the num_features parameter must equal C (the channel dimension), or you get a RuntimeError.

What does the num_features parameter mean?

num_features must equal the number of channels (C) in your input tensor. For BatchNorm2d after a Conv2d with out_channels=64, set num_features=64. For BatchNorm1d after a Linear with out_features=256, set num_features=256.

When should I use BatchNorm1d vs BatchNorm2d?

Use BatchNorm2d for 4D input [batch, C, H, W] (after Conv2d). Use BatchNorm1d for 2D input [batch, features] (after Linear) or 3D input [batch, C, L] (after Conv1d).

Is this tool free?

Yes. All HeyTensor tools are free, run in your browser, and require no signup.

Does this work offline?

Once loaded, the tool runs entirely in your browser. No internet needed after the initial page load.

About This Tool

This tool is part of HeyTensor, a free suite of PyTorch and deep learning utilities. All calculations run entirely in your browser, no calculator inputs or results are sent to any server. The source code is open on GitHub.

Contact

HeyTensor is built and maintained by Michael Lip. For questions or feedback, email [email protected].

TENSOR PREFLIGHT · DOWNLOADABLE PYTORCH TOOLKIT

Take the next step in your own PyTorch model.

Trace a local forward pass, inspect tensor shapes in an HTML report, and turn a repair into a regression check. Includes eight broken-and-fixed workflows, source code and setup instructions.

Is this toolkit right for my problem?

Use the free calculator for a layer formula or a quick shape check.

Consider Tensor Preflight when you have a local PyTorch model and want a forward-pass report plus repeatable checks. Python 3.9+ and PyTorch 2.8+ are required. It does not run your model in this website or automatically repair it.

Open the sample report before buying to check the output format.

Python 3.9+ · PyTorch 2.8+ · Runs locally

Get Tensor Preflight — $29 One-time payment · ZIP download See a sample report
📊 Based on real data from our Most Common PyTorch Errors research — 20 errors ranked by frequency
By the same builder: GitHub, theluckystrike BeLikeNative, Grammar AI EarlyThunder, Dev Blog Bug Bounty Reality Zovo, AI Dev Tools