From 22e30b838e1a89596be6bc5ce4bdd70f303e9c5e Mon Sep 17 00:00:00 2001 From: JunghwanNA <70629228+shaun0927@users.noreply.github.com> Date: Fri, 17 Apr 2026 13:09:56 +0900 Subject: [PATCH] Fix Head.build raising TypeError on body without output_size PR #802 changed the default sentinel in getattr(self.body, "output_size", lambda: None)() to getattr(self.body, "output_size", None)() When the body lacks an output_size attribute, getattr returns None, and the trailing () evaluates None(), which raises TypeError: 'NoneType' object is not callable. The intended raise ValueError("Can't infer output-size...") branch below is never reached. Restore the original callable sentinel so control flow falls through to the descriptive ValueError as designed. Fixes #811 --- transformers4rec/torch/model/base.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/transformers4rec/torch/model/base.py b/transformers4rec/torch/model/base.py index 3aeb4eb3f..e187fac24 100644 --- a/transformers4rec/torch/model/base.py +++ b/transformers4rec/torch/model/base.py @@ -285,7 +285,7 @@ def build(self, inputs=None, device=None, task_blocks=None): device task_blocks """ - if not getattr(self.body, "output_size", None)(): + if not getattr(self.body, "output_size", lambda: None)(): raise ValueError( "Can't infer output-size of the body, please provide " "a `Block` with a output-size. You can wrap any torch.Module in a Block."