Skip to content

Commit

Permalink
Fix all Trainers to support PyTorch DataLoaders (#1703)
Browse files Browse the repository at this point in the history
* Fix all Trainers to support PyTorch DataLoaders

* Add DataLoader Fix For MultiLabelClassification

---------

Co-authored-by: Kay Benkert <[email protected]>
  • Loading branch information
kaybe20 and Kay Benkert authored Oct 28, 2023
1 parent 01fe8d5 commit 906e113
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 0 deletions.
2 changes: 2 additions & 0 deletions torchgeo/trainers/classification.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ def validation_step(
if (
batch_idx < 10
and hasattr(self.trainer, "datamodule")
and hasattr(self.trainer.datamodule, "plot")
and self.logger
and hasattr(self.logger, "experiment")
and hasattr(self.logger.experiment, "add_figure")
Expand Down Expand Up @@ -313,6 +314,7 @@ def validation_step(
if (
batch_idx < 10
and hasattr(self.trainer, "datamodule")
and hasattr(self.trainer.datamodule, "plot")
and self.logger
and hasattr(self.logger, "experiment")
and hasattr(self.logger.experiment, "add_figure")
Expand Down
1 change: 1 addition & 0 deletions torchgeo/trainers/detection.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ def validation_step(
if (
batch_idx < 10
and hasattr(self.trainer, "datamodule")
and hasattr(self.trainer.datamodule, "plot")
and self.logger
and hasattr(self.logger, "experiment")
and hasattr(self.logger.experiment, "add_figure")
Expand Down
1 change: 1 addition & 0 deletions torchgeo/trainers/regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ def validation_step(
if (
batch_idx < 10
and hasattr(self.trainer, "datamodule")
and hasattr(self.trainer.datamodule, "plot")
and self.logger
and hasattr(self.logger, "experiment")
and hasattr(self.logger.experiment, "add_figure")
Expand Down
1 change: 1 addition & 0 deletions torchgeo/trainers/segmentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ def validation_step(
if (
batch_idx < 10
and hasattr(self.trainer, "datamodule")
and hasattr(self.trainer.datamodule, "plot")
and self.logger
and hasattr(self.logger, "experiment")
and hasattr(self.logger.experiment, "add_figure")
Expand Down

0 comments on commit 906e113

Please sign in to comment.