Skip to content

Commit

Permalink
update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
qiauil committed Oct 29, 2024
1 parent 9283e25 commit f7b5058
Show file tree
Hide file tree
Showing 10 changed files with 1,522 additions and 13 deletions.
19 changes: 17 additions & 2 deletions conflictfree/length_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ def rescale_length(
class ProjectionLength(LengthModel):
"""
Rescale the length of the target vector based on the projection of the gradients on the target vector:
$$
|\mathbf{g}_c|=\sum_{i=1}^m|\mathbf{g}_i|\mathcal{S}_c(\mathbf{g}_i,\mathbf{g}_c)
$$
Expand Down Expand Up @@ -160,6 +161,7 @@ class TrackMinimum(_FlexibleTrackProjectionLength):
"""
Rescale the length of the target vector based on the projection of the gradients on the target vector.
All the gradients will be rescaled to the same length as the minimum gradient before projection, i.e., the minimum gradient will be the same length as the target vector.
$$
|\mathbf{g}_c|=\sum_{i=1}^m|\mathbf{g}_{min}|\mathcal{S}_c(\mathbf{g}_i,\mathbf{g}_c)
$$
Expand All @@ -176,6 +178,7 @@ class TrackMaximum(_FlexibleTrackProjectionLength):
"""
Rescale the length of the target vector based on the projection of the gradients on the target vector.
All the gradients will be rescaled to the same length as the maximum gradient before projection, i.e., the maximum gradient will be the same length as the target vector.
$$
|\mathbf{g}_c|=\sum_{i=1}^m|\mathbf{g}_{max}|\mathcal{S}_c(\mathbf{g}_i,\mathbf{g}_c)
$$
Expand All @@ -192,14 +195,18 @@ class TrackHarmonicAverage(_FlexibleTrackProjectionLength):
"""
Rescale the length of the target vector based on the projection of the gradients on the target vector.
All the gradients will be rescaled to the harmonic average of the lengths of all gradients before projection, i.e., the minimum gradient will be the same length as the target vector.
$$
|\mathbf{g}_c|=\sum_{i=1}^m\overline{|\mathbf{g}|}_{harm}\mathcal{S}_c(\mathbf{g}_i,\mathbf{g}_c)
$$
where
$$
\overline{|\mathbf{g}|}_{harm}=\frac{m}{\sum_{i=1}^m \frac{1}{|\mathbf{g}_i|}}
$$
The harmonic average is used to avoid the influence of the large gradients.
The harmonic average can be used to avoid the influence of the large gradients.
"""

def __init__(self):
Expand All @@ -213,10 +220,13 @@ class TrackArithmeticAverage(_FlexibleTrackProjectionLength):
"""
Rescale the length of the target vector based on the projection of the gradients on the target vector.
All the gradients will be rescaled to the arithmetic average of the lengths of all gradients before projection, i.e., the minimum gradient will be the same length as the target vector.
$$
|\mathbf{g}_c|=\sum_{i=1}^m\overline{|\mathbf{g}|}_{arith}\mathcal{S}_c(\mathbf{g}_i,\mathbf{g}_c)
$$
where
$$
\overline{|\mathbf{g}|}_{arith}=\frac{1}{m}\sum_{i=1}^m |\mathbf{g}_i|
$$
Expand All @@ -233,14 +243,18 @@ class TrackGeometricAverage(_FlexibleTrackProjectionLength):
"""
Rescale the length of the target vector based on the projection of the gradients on the target vector.
All the gradients will be rescaled to the geometric average of the lengths of all gradients before projection, i.e., the minimum gradient will be the same length as the target vector.
$$
|\mathbf{g}_c|=\sum_{i=1}^m\overline{|\mathbf{g}|}_{geom}\mathcal{S}_c(\mathbf{g}_i,\mathbf{g}_c)
$$
where
$$
\overline{|\mathbf{g}|}_{geom}=\left(\prod_{i=1}^m |\mathbf{g}_i|\right)^{\frac{1}{m}}
$$
The geometric average is used to avoid the influence of the large gradients.
The geometric average can be used to avoid the influence of the large gradients.
"""

def __init__(self):
Expand All @@ -255,6 +269,7 @@ class TrackSpecific(_FlexibleTrackProjectionLength):
Rescale the length of the target vector based on the projection of the gradients on the target vector.
All the gradients will be rescaled to the same length as the specific gradient before projection.
E.g., if the track_id is 2, then all the gradients will be rescaled to the same length as the third gradient before projection.
$$
|\mathbf{g}_c|=\sum_{i=1}^m\overline{|\mathbf{g}|}_{track_id}\mathcal{S}_c(\mathbf{g}_i,\mathbf{g}_c)
$$
Expand Down
6 changes: 6 additions & 0 deletions docs/api/length_model.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ The `ProjectionLength` class is the default length model for the ConFIG algorith

## Length Model
::: conflictfree.length_model.ProjectionLength
::: conflictfree.length_model.TrackMinimum
::: conflictfree.length_model.TrackMaximum
::: conflictfree.length_model.TrackHarmonicAverage
::: conflictfree.length_model.TrackArithmeticAverage
::: conflictfree.length_model.TrackGeometricAverage
::: conflictfree.length_model.TrackSpecific

## Base Class of Length Model
::: conflictfree.length_model.LengthModel
Binary file added docs/assets/troubleshooting/difweightmodel.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit f7b5058

Please sign in to comment.