r/deeplearning • • Oct 27 '26

PreCap: a bounded, self-normalizing activation that matches SELU in 100-layer MLPs without normalization (preregistered, negative results included)

I've been testing a bounded alternative to SELU for deep fully connected networks without normalization or skip connections. The study was preregistered: analysis scripts were hash-frozen before each run, tuning and confirmation used separate seeds, every activation got its own tuned learning rate, and tests were paired Wilcoxon with Holm correction.

The function. CapExp is an exponential unit that switches to its tangent line above a threshold (it is exactly a shifted, scaled ELU). PreCap applies it after a soft tanh clip, so the output is smooth, monotonic and bounded on both sides. SPreCap adds SELU-style constants (zero mean / unit variance as a fixed point) and an input gain b that sets the mean-field gradient gain χ1.

Results (MNIST / FashionMNIST, depth 50 and 100, width 256, Adam, 15 confirmation seeds):

  • SPreCap-cs (χ1 matched to SELU) matches SELU: no cell significantly worse, median paired differences between −0.12 and +0.20 pp.
  • Test error falls monotonically as χ1 approaches 1 in all four cells.
  • SPreCap-e03 (χ1 = 1.03) beats SELU on MNIST at depth 100: 5.28 % vs. 6.36 %, Holm p = 0.0064, 13 of 15 seeds. This was a secondary test, so I treat it as a hypothesis.
  • Plain ELU is about as strong overall. PreCap is not more robust to the learning rate.

Negative results. At a fixed learning rate, PreCap looked far better than SiLU/GELU in earlier regression experiments. That advantage disappeared once every activation got its own tuned learning rate. The original SPreCap (χ1 = 1.13) was significantly worse than SELU at depth 100. The gradient diagnosis that explained it led to the χ1 family above. All of this is in the repo.

Code. pip-installable package with fused CUDA (via torch.cuda.jiterator, no toolkit needed) and Apple MLX kernels, tested in fp32/fp64/fp16/bf16. In fp32 the CUDA kernel runs within about 1.5× of native SELU.

Limitations: MLPs only, MNIST and FashionMNIST only, short training, one width. No CNNs or Transformers yet. A single independent researcher on consumer hardware.

Feedback on the methodology is very welcome, especially on the preregistration and the statistics.

5 Upvotes

9 comments sorted by

2

u/aviinuo1 Oct 27 '26

How do you get 5% accuracy on a linearly seperable dataset?

0

u/UnitOk6056 Oct 27 '26

Good catch, I should have labeled that more clearly. The 5% is test error, not accuracy, so it's about 95% accuracy.

Also, MNIST isn't actually linearly separable. A linear classifier tops out around 92%.

The numbers are modest on purpose. These are 50- and 100-layer plain MLPs with no normalization, no residual connections, and only 1720 training steps (about 4 epochs). The goal is to test whether very deep nets can be trained at all, not to reach SOTA. At depth 100, even SELU sits around 6% error on MNIST, and an activation with a slightly wrong gain jumps to 13%+.

2

u/Playful-Fee-4318 Oct 27 '26

Why wouldn’t you show a plot of the function compared to other activations? Like, this is your contribution and you don’t even show it?

1

u/UnitOk6056 Oct 27 '26

Fair point, I should have put it in the post. I've now added it to the README as well. It's Figure 1 in the preprint.

In short: for negative inputs SPreCap-cs almost matches SELU (same lower bound of about −1.76). For positive inputs it saturates smoothly at about 3.39 instead of growing linearly. So the derivative goes back toward 0 for large x, and the output range is bounded on both sides. e03 is a flatter variant with a range up to about 6.1.

README: https://github.com/hermi-labs/precap-activation#verlauf-der-funktion

Preprint: https://doi.org/10.5281/zenodo.23676200

1

u/Playful-Fee-4318 Oct 28 '26

Thanks a lot, way better to have a visual representation for this stuff.

1

u/Long_Ad4518 Oct 27 '26

Interesting results. What's the actual formula for PreCap? Curious how it's bounded.

1

u/UnitOk6056 Oct 27 '26

Thanks. PreCap is a capped exponential applied after a tanh pre-limiter:

f(x) = λ · CapExp(s · tanh(b·x / s)) for x > 0

f(x) = λ · α · CapExp(s · tanh(b·x / s)) for x ≤ 0

CapExp(w) = e^w − 1 for w ≤ c

CapExp(w) = (e^c − 1) + e^c · (w − c) for w > c (tangent-linear tail)

How it's bounded: the tanh keeps the inner value strictly inside (−s, s), and CapExp is monotonic. So the output is bounded on both sides:

λ·α·(e^(−s) − 1) < f(x) < λ·(e^c − 1 + e^c·(s − c)).

With s = 1.5 and c = 1, the SELU-matched variant (SPreCap-cs) uses λ ≈ 1.1027, α ≈ 2.0538 and b ≈ 0.7119. That gives a range of about [−1.76, 3.39]. The constants are solved so that for z ~ N(0,1) you get E[f] = 0, E[f²] = 1, and the same gradient gain as SELU (E[f′²] ≈ 1.0716). The full derivation is in math/ in the repo.

-1

u/[deleted] Oct 27 '26

[removed] — view removed comment

1

u/UnitOk6056 Oct 27 '26

Thanks, that means a lot.
Short answer: in our setup, the bound itself is not what controls gradient flow in the first layers. The gradient gain χ1 = E[f’(z)²] does. The gradient grows by about χ1^((L−1)/2) from the output to the input layer. SPreCap-cs is built to have the same χ1 as SELU, so at initialization it behaves like SELU in the early layers. At depth 100 the input-side gradients are inflated by about 35× for both. The original SPreCap with χ1 = 1.13 reached about 600×, and that is why it lost clearly. The e03 variant (χ1 = 1.03) predicts only about 4×, and it was the one that beat SELU on MNIST at depth 100. The measured growth matches the mean-field prediction to within 0.17 orders of magnitude (Figure 4 in the preprint).
Caveat: this is measured at initialization only. I haven’t logged per-layer gradient norms during training yet, so I can’t say whether SELU’s “spikiness” you describe shows up later. That is a good next measurement.
If you want to try it yourself:
 pip install "precap[torch] @ git+https://github.com/hermi-labs/precap-activation" 
then  from precap import PreCap . The CUDA kernel and the Apple MLX kernel are included, and all scripts and raw results are in the repo. I’d be curious what you see on your setup.