Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ repos:
- id: check-merge-conflict # Check for files that contain merge conflict strings.

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.16.0
rev: v0.16.5
hooks:
- id: ruff-check
args: [ --fix, --ignore, FIX ] # Allow committing with TODOs. Only CI checks should prevent merging with TODOs.
Expand Down
10 changes: 7 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,16 +117,18 @@ changelog does not include internal changes that do not affect the user.
```python
# Before
from torchjd.aggregation import Flattening, UPGradWeighting

weighting = Flattening(UPGradWeighting())
gramian = engine.compute_gramian(losses) # shape: [m1, m2, m2, m1]
weights = weighting(gramian) # shape: [m1, m2]
weights = weighting(gramian) # shape: [m1, m2]
losses.backward(weights)

# After
from torchjd.aggregation import UPGradWeighting

weighting = UPGradWeighting()
gramian = engine.compute_gramian(losses) # shape: [m1 * m2, m1 * m2]
weights = weighting(gramian).reshape(losses.shape) # shape: [m1, m2]
gramian = engine.compute_gramian(losses) # shape: [m1 * m2, m1 * m2]
weights = weighting(gramian).reshape(losses.shape) # shape: [m1, m2]
losses.backward(weights)
```

Expand All @@ -140,11 +142,13 @@ changelog does not include internal changes that do not affect the user.
```python
# Before
from torchjd.aggregation import UPGrad

aggregator = UPGrad(norm_eps=1e-6, reg_eps=1e-6, solver="quadprog")

# After
from torchjd.aggregation import UPGrad
from torchjd.linalg import QuadprogProjector

aggregator = UPGrad(projector=QuadprogProjector(norm_eps=1e-6, reg_eps=1e-6))
```
If you used the default `norm_eps`, `reg_eps` and `solver`, you don't have to change anything and
Expand Down
2 changes: 2 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,11 +174,13 @@ device and dtype, you have to use the partial functions defined in `tests/utils/
instantiate tensors. For instance, instead of
```python
import torch

a = torch.ones(3, 4)
```
use
```python
from utils.tensors import ones_

a = ones_(3, 4)
```

Expand Down
11 changes: 3 additions & 8 deletions skills/implement-method/references/aggregators.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,11 @@ allows safe mutation after construction and gives immediate, clear error message
def alpha(self) -> float:
return self._alpha


@alpha.setter
def alpha(self, value: float) -> None:
if not (0.0 <= value <= 1.0):
raise ValueError(
f"Attribute `alpha` must be in [0, 1]. Found alpha={value!r}."
)
raise ValueError(f"Attribute `alpha` must be in [0, 1]. Found alpha={value!r}.")
self._alpha = value
```

Expand Down Expand Up @@ -164,11 +163,7 @@ already defines `__str__` to return just the class name, and `Weighting` inherit

```python
def __repr__(self) -> str:
return (
f"{self.__class__.__name__}("
f"alpha={self.alpha!r}, "
f"rho={self.rho!r})"
)
return f"{self.__class__.__name__}(alpha={self.alpha!r}, rho={self.rho!r})"
```

---
Expand Down
Loading