-
Notifications
You must be signed in to change notification settings - Fork 322
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Jirka Borovec <[email protected]> Co-authored-by: Jirka B <[email protected]>
- Loading branch information
1 parent
3d1c652
commit 4ef2750
Showing
4 changed files
with
158 additions
and
90 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
Empty file.
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,24 @@ | ||
import functools | ||
import operator | ||
|
||
import pytorch_lightning as pl | ||
|
||
from pl_bolts import datamodules | ||
from pl_bolts.models import regression | ||
|
||
|
||
def test_logistic_regression_model(datadir): | ||
pl.seed_everything(0) | ||
|
||
dm = datamodules.MNISTDataModule(datadir) | ||
|
||
model = regression.LogisticRegression( | ||
input_dim=functools.reduce(operator.mul, dm.dims, 1), num_classes=10, learning_rate=0.001 | ||
) | ||
|
||
trainer = pl.Trainer(max_epochs=3, logger=False, enable_checkpointing=False) | ||
trainer.fit(model, datamodule=dm) | ||
trainer.test(model, datamodule=dm) | ||
assert trainer.state.finished | ||
assert trainer.callback_metrics["test_acc"] > 0.9 | ||
assert trainer.callback_metrics["test_loss"] < 0.3 |
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