facebookresearch / facebookresearch/tribev2

Bug: TemporalSmoothing conv layer not actually frozen (requires_grad_ not called correctly)

Open Beginner friendly
#5 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Jupyter Notebook
Stars
3.2k
Forks
695
PR merge metrics
No merged PRs in 30d

Description

## Bug Description

In `tribev2/model.py`, the `TemporalSmoothing` module attempts to freeze its convolutional layer's parameters by setting:

```python
conv.requires_grad = False
```

This does **nothing**. `nn.Module` does not have a `requires_grad` attribute — this just sets a plain Python attribute on the module object, leaving all parameters fully trainable. The Gaussian kernel **will still be updated by the optimizer**, defeating the intent to keep it fixed.

## Expected Behavior

The Gaussian kernel in `TemporalSmoothing` should be frozen and not updated during training.

## Actual Behavior

The kernel is updated by the optimizer because `requires_grad` on the parameters is never actually set to `False`.

## Fix

```python
# Wrong
conv.requires_grad = False

# Correct
conv.requires_grad_(False)
```

`requires_grad_()` is the in-place method on `nn.Module` that correctly sets `requires_grad = False` on all parameters within the module.

## References

- [PyTorch docs: Module.requires_grad_](https://pytorch.org/docs/stable/generated/torch.nn.Module.html#torch.nn.Module.requires_grad_)

## Environment

- Tested against current `main` branch

Contributor guide

Open the contributing guide

Research direction

Open tribev2/model.py and inspect the TemporalSmoothing module's convolution setup. Replace the ineffective freeze operation with the documented module-level behavior, then verify that the Gaussian kernel parameters no longer require gradients during training; done means the optimizer cannot update them.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
machine-learning
Issue type
Bug
Difficulty
1/5
Estimated time
Under an hour
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.