# units=None set in EquivariantLayer()?

**URL:** <https://discuss.bayesflow.org/t/units-none-set-in-equivariantlayer/220>\
**Category:** General\
**Created:** [January 9, 2026, 8:40am UTC](https://discuss.bayesflow.org/t/units-none-set-in-equivariantlayer/220 "2026-01-09T08:40:15Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![m-schuettler](https://avatars.discourse-cdn.com/v4/letter/m/ea666f/32.png) [@m-schuettler](https://discuss.bayesflow.org/u/m-schuettler)\
**Post date:** [January 9, 2026, 8:40am UTC](https://discuss.bayesflow.org/t/units-none-set-in-equivariantlayer/220/1 "2026-01-09T08:40:15Z")

</div>

Hi everyone! I’m new to BayesFlow and new-ish to ML in general, so maybe this is a stupid question.

I’m trying to run someone else’s code, but I’m always getting an error message when trying to run `EquivariantLayer()`. This is the error message I’m getting:

```auto
Traceback (most recent call last):
File “C:\\Users\\####\\Desktop\\ABI-graph-paper\\case_study_toy\\toy_run_simulation.py”, line 260, in 
sum_net_ds_mp = DeepSetMeanPooling(summary_dim=16, mlp_widths_equivariant=(64,64))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “C:\\Users\\####\\Desktop\\ABI-graph-paper\\case_study_toy..\\summary_networks\\DeepSetMeanPooling.py”, line 92, in **init**
equivariant_module = EquivariantLayer(
^^^^^^^^^^^^^^^^^
File “C:\\Users\\####\\Desktop\\ABI-graph-paper.venv\\Lib\\site-packages\\bayesflow\\networks\\deep_set\\equivariant_layer.py”, line 78, in **init**
self.invariant_module = InvariantLayer(
^^^^^^^^^^^^^^^
File “C:\\Users\\####\\Desktop\\ABI-graph-paper.venv\\Lib\\site-packages\\bayesflow\\networks\\deep_set\\invariant_layer.py”, line 70, in **init**
self.inner_fc = MLP(
^^^^
File “C:\\Users\\####\\Desktop\\ABI-graph-paper.venv\\Lib\\site-packages\\bayesflow\\networks\\mlp\\mlp.py”, line 74, in **init**
block = self.\_make_block(
^^^^^^^^^^^^^^^^^
File “C:\\Users\\####\\Desktop\\ABI-graph-paper.venv\\Lib\\site-packages\\bayesflow\\networks\\mlp\\mlp.py”, line 129, in \_make_block
return Residual(\*layers)
^^^^^^^^^^^^^^^^^
File “C:\\Users\\####\\Desktop\\ABI-graph-paper.venv\\Lib\\site-packages\\bayesflow\\networks\\residual\\residual.py”, line 23, in **init**
self.projector = keras.layers.Dense(units=None, name=“projector”)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “C:\\Users\\####\\Desktop\\ABI-graph-paper.venv\\Lib\\site-packages\\keras\\src\\layers\\core\\dense.py”, line 101, in **init**
raise ValueError(
ValueError: Received an invalid value for units, expected a positive integer. Received: units=None

```

So BayesFlow sets `units=None`, even though Keras only allows positive integers? Am I missing something? I first thought this was maybe a compatibility issue with the versions I have installed, but older Keras versions also don’t allow None values for `units`.

In case it matters, I’m using Python 3.12.4, BayesFlow 2.0.7 with TensorFlow 2.20.0 backend and Keras 3.13.0.

ETA: In the meantime, I found that it works without raising an error with the latest dev version of BayesFlow, even though I still don’t understand what causes this error in the first place

---

<div class="post-metadata">

**Author:** ![discourse\_ai\_spam](https://avatars.discourse-cdn.com/v4/letter/d/c68b51/32.png) [@discourse\_ai\_spam](https://discuss.bayesflow.org/u/discourse_ai_spam)\
**Post date:** [January 9, 2026, 1:44pm UTC](https://discuss.bayesflow.org/t/units-none-set-in-equivariantlayer/220/2 "2026-01-09T13:44:45Z")

</div>

Unlisted on January 9, 2026, 1:44pm UTC



---

<div class="post-metadata">

**Author:** ![KLDivergence](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.bayesflow.org/kldivergence/32/15_2.png) [@KLDivergence](https://discuss.bayesflow.org/u/KLDivergence)\
**Post date:** [January 9, 2026, 2:32pm UTC](https://discuss.bayesflow.org/t/units-none-set-in-equivariantlayer/220/3 "2026-01-09T14:32:08Z")

</div>

Opened on January 9, 2026, 2:32pm UTC



---

<div class="post-metadata">

**Author:** ![KLDivergence](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.bayesflow.org/kldivergence/32/15_2.png) [@KLDivergence](https://discuss.bayesflow.org/u/KLDivergence)\
**Post date:** [January 9, 2026, 2:36pm UTC](https://discuss.bayesflow.org/t/units-none-set-in-equivariantlayer/220/4 "2026-01-09T14:36:04Z")

</div>

Listed on January 9, 2026, 2:36pm UTC



---

<div class="post-metadata">

**Author:** ![KLDivergence](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.bayesflow.org/kldivergence/32/15_2.png) [@KLDivergence](https://discuss.bayesflow.org/u/KLDivergence)\
**Post date:** [January 9, 2026, 2:37pm UTC](https://discuss.bayesflow.org/t/units-none-set-in-equivariantlayer/220/5 "2026-01-09T14:37:31Z")

</div>

The discourse AI mistakenly flagged this post, sorry for that. Could you please repost?

---

<div class="post-metadata">

**Author:** ![m-schuettler](https://avatars.discourse-cdn.com/v4/letter/m/ea666f/32.png) [@m-schuettler](https://discuss.bayesflow.org/u/m-schuettler)\
**Post date:** [January 9, 2026, 2:43pm UTC](https://discuss.bayesflow.org/t/units-none-set-in-equivariantlayer/220/6 "2026-01-09T14:43:51Z")

</div>

Thanks for listing it again, I wasn’t sure what’s going on there 😅

---

<div class="post-metadata">

**Author:** ![KLDivergence](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.bayesflow.org/kldivergence/32/15_2.png) [@KLDivergence](https://discuss.bayesflow.org/u/KLDivergence)\
**Post date:** [January 9, 2026, 4:13pm UTC](https://discuss.bayesflow.org/t/units-none-set-in-equivariantlayer/220/7 "2026-01-09T16:13:32Z")

</div>

Version 2.0.8 (from dev) will be coming to main very soon, so this should be resolved soon. `None` can be passed to layers in the context of lazy initialization.

---

<div class="post-metadata">

**Author:** ![Simon](https://avatars.discourse-cdn.com/v4/letter/s/f07891/32.png) [@Simon](https://discuss.bayesflow.org/u/Simon)\
**Post date:** [January 13, 2026, 9:16am UTC](https://discuss.bayesflow.org/t/units-none-set-in-equivariantlayer/220/8 "2026-01-13T09:16:20Z")

</div>

Hi, I don’t know why the error happens. I had the same issue and solved it by installing different versions.  
These work for me:  
bayesflow==2.0.7  
keras==3.11.3  
tensorflow==2.20.0  
python==3.10.11

---

<div class="post-metadata">

**Author:** ![KLDivergence](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.bayesflow.org/kldivergence/32/15_2.png) [@KLDivergence](https://discuss.bayesflow.org/u/KLDivergence)\
**Post date:** [January 13, 2026, 3:45pm UTC](https://discuss.bayesflow.org/t/units-none-set-in-equivariantlayer/220/9 "2026-01-13T15:45:58Z")

</div>

It seems that indeed it’s an upstream issue with newer `keras` releases. This will be fixed in:

> <https://github.com/bayesflow-org/bayesflow/pull/610>
>
> This changes how the \`output\_projector\` layer is initialized in the \`SingleCoupl…ing\` class. The main change is that the layer is no longer created during object instantiation, but is instead initialized in the \`build\` method where the necessary shape information is available. With keras 3.13.0, I could not use pass \`None\` to the \`Dense\` layer.
