Skip to content

Commit 9ff5847

Browse files
Linter Fixes
1 parent 3a458d2 commit 9ff5847

File tree

3 files changed

+10
-15
lines changed

3 files changed

+10
-15
lines changed

vissl/data/ssl_transforms/img_pil_color_distortion.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class ImgPilColorDistortion(ClassyTransform):
2121
randomly convert the image to grayscale.
2222
"""
2323

24-
def __init__(self, strength , brightness=0.8 , contrast=0.8 , saturation=0.8,
24+
def __init__(self, strength , brightness=0.8 , contrast=0.8 , saturation=0.8,
2525
hue=0.2,color_jitter_probability=0.8,grayscale_probability=0.2):
2626
"""
2727
Args:
@@ -35,11 +35,11 @@ def __init__(self, strength , brightness=0.8 , contrast=0.8 , saturation=0.8,
3535
jitter saturation. Default value is 0.8.
3636
hue (float): A floating point number used to quantify
3737
jitter hue. Default value is 0.2.
38-
color_jitter_probability (float): A floating point number used to
39-
quantify to apply randomly a list of transformations
38+
color_jitter_probability (float): A floating point number used to
39+
quantify to apply randomly a list of transformations
4040
with a given probability. Default value is 0.8.
41-
grayscale_probability (float): A floating point number used to
42-
quantify to apply randomly convert image to grayscale with
41+
grayscale_probability (float): A floating point number used to
42+
quantify to apply randomly convert image to grayscale with
4343
the assigned probability. Default value is 0.2.
4444
This function follows the Pytorch documentation: https://pytorch.org/vision/stable/transforms.html
4545
"""

vissl/hooks/byol_hooks.py

+3-5
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,9 @@
44

55
import torch
66
from classy_vision import tasks
7-
from classy_vision.generic.distributed_util import is_distributed_training_run
87
from classy_vision.hooks.classy_hook import ClassyHook
98
from vissl.models import build_model
109
from vissl.utils.env import get_machine_local_and_dist_rank
11-
from vissl.utils.misc import concat_all_gather
1210

1311
class BYOLHook(ClassyHook):
1412
"""
@@ -94,7 +92,7 @@ def _update_momentum_coefficient(self, task: tasks.ClassyTask) -> None:
9492
if self.total_iters is None:
9593

9694
self.total_iters = task.max_iteration
97-
logging.info(f"{self.total_iters} total iters")
95+
logging.info(f"{self.total_iters} total iters")
9896
training_iteration = task.iteration
9997
self.momentum = self.target_ema(training_iteration, self.base_momentum, self.total_iters)
10098

@@ -118,8 +116,8 @@ def _update_target_network(self, task: tasks.ClassyTask) -> None:
118116
@torch.no_grad()
119117
def on_forward(self, task: tasks.ClassyTask) -> None:
120118
"""
121-
Creates a target network needed for Contrastive learning
122-
on which BYOL is based. It then updates the target network's
119+
Creates a target network needed for Contrastive learning
120+
on which BYOL is based. It then updates the target network's
123121
parameters based on the online network's parameters.
124122
This function also computer and saves target embeddings,
125123
which need be can be used for further downstream tasks.

vissl/losses/byol_loss.py

+2-5
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,14 @@
66
import torch
77
import torch.nn.functional as F
88
from classy_vision.losses import ClassyLoss, register_loss
9-
from torch import nn
10-
from vissl.utils.misc import concat_all_gather
11-
129

1310
_BYOLLossConfig = namedtuple(
1411
"_BYOLLossConfig", ["embedding_dim", "momentum"]
1512
)
1613

1714
def regression_loss(x, y):
1815
"""
19-
This function is used for computing loss between the prediction
16+
This function is used for computing loss between the prediction
2017
from the Online network and projection from the target network.
2118
We can either use L2 normalized Root mean squared or
2219
Cosine similarity. This implementation uses Cosine similarity.
@@ -39,7 +36,7 @@ def defaults() -> "BYOLLossConfig":
3936
@register_loss("byol_loss")
4037
class BYOLLoss(ClassyLoss):
4138
"""
42-
This is the loss proposed in BYOL
39+
This is the loss proposed in BYOL
4340
- Bootstrap your own latent: (https://arxiv.org/abs/2006.07733)
4441
This class wraps functions which computes
4542
- loss

0 commit comments

Comments
 (0)