Skip to content

AttributeError: 'list' object has no attribute 'shape' when using saliency map with teacher model and head distillation #2

@rezafuru

Description

@rezafuru

Description:
When using a DataLoader that returns a tuple of (tensor, saliency_map) in __getitem__, and running head distillation with a teacher model (i.e., without bottleneck injection), the forward pass fails with the following error:

AttributeError: 'list' object has no attribute 'shape'

Cause:
The issue arises because the saliency-augmented input is not properly unpacked before being forwarded through the teacher model, which expects a plain tensor and not a tuple/list.

Traceback snippet:

File "patch_embed.py", line 50, in forward
  B, C, H, W = x.shape
AttributeError: 'list' object has no attribute 'shape'

Steps to Reproduce:

  1. Use a dataset where __getitem__ returns (tensor, saliency_map)
  2. Enable head distillation
  3. Train using a teacher model (no bottleneck injection)

Expected Behavior:
The teacher model should correctly receive just the tensor (not the tuple) in the forward pass.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions