Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix SSL hooks fro pl 1.0 #277

Merged
merged 2 commits into from
Oct 15, 2020
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
4 changes: 2 additions & 2 deletions pl_bolts/callbacks/self_supervised.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def to_device(self, batch, device):

return x, y

def on_train_batch_end(self, trainer, pl_module, batch, batch_idx, dataloader_idx):
def on_train_batch_end(self, trainer, pl_module, outputs, batch, batch_idx, dataloader_idx):
x, y = self.to_device(batch, pl_module.device)

with torch.no_grad():
Expand Down Expand Up @@ -131,7 +131,7 @@ def __init__(self, initial_tau=0.996):
self.initial_tau = initial_tau
self.current_tau = initial_tau

def on_train_batch_end(self, trainer, pl_module, batch, batch_idx, dataloader_idx):
def on_train_batch_end(self, trainer, pl_module, outputs, batch, batch_idx, dataloader_idx):
# get networks
online_net = pl_module.online_network
target_net = pl_module.target_network
Expand Down
2 changes: 1 addition & 1 deletion pl_bolts/callbacks/vision/confused_logit.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def __init__(
self.logging_batch_interval = logging_batch_interval
self.min_logit_value = min_logit_value

def on_train_batch_end(self, trainer, pl_module, batch, batch_idx, dataloader_idx):
def on_train_batch_end(self, trainer, pl_module, outputs, batch, batch_idx, dataloader_idx):
# show images only every 20 batches
if (trainer.batch_idx + 1) % self.logging_batch_interval != 0:
return
Expand Down
4 changes: 2 additions & 2 deletions pl_bolts/models/self_supervised/byol/byol_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,9 @@ def __init__(self,
self.target_network = deepcopy(self.online_network)
self.weight_callback = BYOLMAWeightUpdate()

def on_train_batch_end(self, batch: Any, batch_idx: int, dataloader_idx: int) -> None:
def on_train_batch_end(self, outputs, batch: Any, batch_idx: int, dataloader_idx: int) -> None:
# Add callback for user automatically since it's key to BYOL weight update
self.weight_callback.on_train_batch_end(self.trainer, self, batch, batch_idx, dataloader_idx)
self.weight_callback.on_train_batch_end(self.trainer, self, outputs, batch, batch_idx, dataloader_idx)

def forward(self, x):
y, _, _ = self.online_network(x)
Expand Down