From 5ebe94d2d200c516f6cfbd3a0b237636034178b4 Mon Sep 17 00:00:00 2001 From: Florian Frantzen Date: Mon, 24 Aug 2026 13:30:09 +0200 Subject: [PATCH 1/2] Fix AllSet instantiation with default activation AllSet defaulted mlp_activation to None, which overrode the nn.ReLU default of AllSetLayer and reached the MLP helper, where the activation class was called unconditionally, raising TypeError: 'NoneType' object is not callable on construction. - Default mlp_activation to torch.nn.ReLU in AllSet - Skip None activations in both copy-pasted MLP helpers, mirroring the existing norm_layer guard - Apply the same fixes to AllSetTransformerBlock and its MLP helper, which shared the latent bug Fixes #307 --- topomodelx/nn/hypergraph/allset.py | 2 +- topomodelx/nn/hypergraph/allset_layer.py | 3 ++- topomodelx/nn/hypergraph/allset_transformer_layer.py | 5 +++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/topomodelx/nn/hypergraph/allset.py b/topomodelx/nn/hypergraph/allset.py index 0219747f..b13e496c 100644 --- a/topomodelx/nn/hypergraph/allset.py +++ b/topomodelx/nn/hypergraph/allset.py @@ -46,7 +46,7 @@ def __init__( n_layers=2, layer_dropout=0.2, mlp_num_layers=2, - mlp_activation=None, + mlp_activation=torch.nn.ReLU, mlp_dropout=0.0, mlp_norm=None, **kwargs, diff --git a/topomodelx/nn/hypergraph/allset_layer.py b/topomodelx/nn/hypergraph/allset_layer.py index e32f0513..a19353c6 100644 --- a/topomodelx/nn/hypergraph/allset_layer.py +++ b/topomodelx/nn/hypergraph/allset_layer.py @@ -175,7 +175,8 @@ def __init__( layers.append(nn.Linear(in_dim, hidden_dim, bias=bias)) if norm_layer is not None: layers.append(norm_layer(hidden_dim)) - layers.append(activation_layer(**params)) + if activation_layer is not None: + layers.append(activation_layer(**params)) layers.append(nn.Dropout(dropout, **params)) in_dim = hidden_dim diff --git a/topomodelx/nn/hypergraph/allset_transformer_layer.py b/topomodelx/nn/hypergraph/allset_transformer_layer.py index 652e8d71..4a79e847 100644 --- a/topomodelx/nn/hypergraph/allset_transformer_layer.py +++ b/topomodelx/nn/hypergraph/allset_transformer_layer.py @@ -191,7 +191,7 @@ def __init__( number_queries: int = 1, dropout: float = 0.0, mlp_num_layers: int = 1, - mlp_activation=None, + mlp_activation=nn.ReLU, mlp_dropout: float = 0.0, mlp_norm=None, initialization: Literal["xavier_uniform", "xavier_normal"] = "xavier_uniform", @@ -455,7 +455,8 @@ def __init__( layers.append(nn.Linear(in_dim, hidden_dim, bias=bias)) if norm_layer is not None: layers.append(norm_layer(hidden_dim)) - layers.append(activation_layer(**params)) + if activation_layer is not None: + layers.append(activation_layer(**params)) layers.append(nn.Dropout(dropout, **params)) in_dim = hidden_dim From 8b99f8f01575a8a97d5159513396404ab0553688 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 25 Aug 2026 06:40:25 +0000 Subject: [PATCH 2/2] Update AllSet mlp_activation docstring default/type Co-authored-by: ffl096 <2105496+ffl096@users.noreply.github.com> --- topomodelx/nn/hypergraph/allset.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/topomodelx/nn/hypergraph/allset.py b/topomodelx/nn/hypergraph/allset.py index b13e496c..9abc2c20 100644 --- a/topomodelx/nn/hypergraph/allset.py +++ b/topomodelx/nn/hypergraph/allset.py @@ -22,7 +22,7 @@ class AllSet(torch.nn.Module): Dropout probability for the AllSet layer. mlp_num_layers : int, default = 2 Number of layers in the MLP. - mlp_activation : torch.nn.Module, default = None + mlp_activation : callable | None, default = torch.nn.ReLU Activation function in the MLP. mlp_dropout : float, default = 0.0 Dropout probability for the MLP.