MagNet legacy B–H Transformers (ONNX preview)
These are the ten material-specific steady-state B–H Transformer checkpoints from the original Princeton MagNet application, converted to fixed-shape ONNX encoder and decoder graphs. The release is a numerical port of the legacy inference, not a newly trained model or an independently certified accuracy benchmark. It does not contain a transient neural model.
The available materials are 3C90, 3C94, 3E6, 3F4, 77, 78, N27, N30, N49, and N87. There are no legacy Transformer checkpoints for the other five materials in the public 15-material steady-state dataset.
Files and inference contract
Each material folder contains encoder.onnx, decoder.onnx, norm.json, and
reference.json. These ONNX files and JSON normalizers are the preferred
inference artifacts. pytorch/Model_<material>_Transformer.sd and
pytorch/Norm_<material>.pt are the original, unmodified PyTorch weights and
normalizers, included for provenance and reproducibility; they are not
needed for ONNX inference. If you inspect them with PyTorch, use
torch.load(path, map_location="cpu", weights_only=True) and verify the
SHA-256 values in reference.json. Do not use unrestricted pickle loading.
domain/hull_<material>.npy stores the corresponding measured-data
operating-domain hull equations. predict.py is a standalone CPU example
using NumPy and ONNX Runtime; see requirements.txt.
- Input: 128 finite, uniformly sampled magnetic flux-density values B in T over one cycle, without a repeated closing sample; frequency f in Hz (strictly positive); temperature °C; and DC magnetic field bias A/m.
norm.jsoncontains ten float32-origin values. Normalize B with(B - n[0]) / n[1],log10(f)with(log10(f) - n[2]) / n[3], temperature with(temperature - n[4]) / n[5], and DC bias with(bias - n[6]) / n[7].- The encoder takes
sourcefloat32[1,128,1]andvariablesfloat32[1,3]in[log10(f), temperature, bias]order after normalization. Itsmemoryoutput is[1,128,24]. - Initialize decoder
targetfloat32[1,129,1]to zero and set its first value to0.1. Call the decoder 128 times, setting target valuetto decoder output valuet-1fort=1…128; then call it once more. The decoder takesmemoryandtarget; itsoutputis[1,129,1]. - Output: the first 128 decoder outputs give H in A/m after
H = output * n[9] + n[8]. The signed volumetric loop integral isf * trapezoid(H, B)in W/m³, using the 127 adjacent sample intervals. This reproduces the historical implementation; it does not add a synthetic closing edge. A negative signed result should be inspected, not silently converted to a positive loss.
The provided sine and triangle generator follows the original 128-point waveform convention. The triangle duty ratio is the normalized time of its positive B peak and must be strictly between zero and one. A custom 128-point B waveform is also accepted; the measured-data hull test is then left undetermined because the original hull uses an ideal-waveform duty coordinate.
Operating domain and limitations
The historical hull is a five-dimensional convex hull of measured operating
points in this order: [frequency_Hz, peak_AC_flux_T, DC_bias_A_per_m, temperature_C, duty_ratio]. Each row of domain/hull_<material>.npy is an
inequality [a0,a1,a2,a3,a4,b] with a·point + b <= 1e-10 for an in-hull
point. For ideal sine waves the duty coordinate is 0.5; for triangular waves
it is the specified duty ratio. A hull pass indicates only that the operating
point lies within this geometric domain; it is not an accuracy guarantee.
The examples still return a prediction outside the hull and flag it.
All ten nominal sine-wave packages passed local PyTorch-to-ONNX numerical
parity tests; the largest relative difference in predicted loss was
8.71e-7. N87 was also checked at seven sine/triangle operating points,
including 30% and 70% triangle duty, 25–90 °C, 0/30 A/m DC bias, and two
frequencies; the largest observed relative difference was 1.50e-6. A
Chrome/ONNX Runtime Web smoke test passed the ten reference cases, with a
largest relative difference from PyTorch of 7.66e-7. Per-material
reference.json includes one PyTorch B/H reference waveform, parity result,
and SHA-256 hashes of the source checkpoint, normalizer, and architecture.
Four N87 measurements were compared at recorded operating points as a sanity check only using generated ideal waveforms. They may overlap the original training data. The original training split and full provenance have not been reconstructed, and no independent generalization metric is claimed. These models must not be treated as validated material datasheets, especially for extrapolated operating points. The related public data are available at minjiechen/MagNet, but their present release files have not been established as the exact training set for these legacy checkpoints.
Quick start
With Python 3.12 and the packages in requirements.txt installed:
python predict.py --material N87 --waveform sine --frequency-hz 100000 \
--flux-t 0.1 --temperature-c 25 --bias-a-per-m 0
python predict.py --material N87 --waveform triangle --duty 0.3 \
--frequency-hz 100000 --flux-t 0.1 --temperature-c 25
Use --b-json path/to/waveform.json instead of --waveform and --flux-t
for a JSON array of 128 B values in T. Do not execute model files from
untrusted sources. The example does not load the original PyTorch archives.
Provenance, license, and citation
The original architecture, weights, and hulls come from the Princeton MagNet source repository, under its MIT license (copyright 2021 Minjie Chen). The converted ONNX files preserve that license; the related public measurement datasets have a separate CC BY 4.0 license. Maintainer: Princeton Power Electronics Research Lab / Minjie Chen.
Please cite: H. Li et al., “How MagNet: Machine Learning Framework for Modeling Power Magnetic Material Characteristics,” IEEE Transactions on Power Electronics (2023), doi:10.1109/TPEL.2023.3309232.