forked from AntixK/PyTorch-VAE
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix for data_loader in pl version 0.7
- Loading branch information
Showing
2 changed files
with
28 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import pytorch_lightning as pl | ||
|
||
|
||
## Utils to handle newer PyTorch Lightning changes from version 0.6 | ||
## ==================================================================================================== ## | ||
|
||
|
||
def data_loader(fn): | ||
""" | ||
Decorator to handle the deprecation of data_loader from 0.7 | ||
:param fn: User defined data loader function | ||
:return: A wrapper for the data_loader function | ||
""" | ||
|
||
def func_wrapper(self): | ||
try: # Works for version 0.6.0 | ||
return pl.data_loader(fn)(self) | ||
|
||
except: # Works for version > 0.6.0 | ||
return fn(self) | ||
|
||
return func_wrapper |