Skip to content

Commit

Permalink
added a warning when a PyTorch model is in train mode (#78)
Browse files Browse the repository at this point in the history
* added a warning when a PyTorch model is in train mode

* added missing import
  • Loading branch information
jonasrauber committed Oct 6, 2017
1 parent fcbbc6f commit 76407ec
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions foolbox/models/pytorch.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import numpy as np
import warnings

from .base import DifferentiableModel

Expand Down Expand Up @@ -43,6 +44,12 @@ def __init__(
self._model = model
self.cuda = cuda

if model.training:
warnings.warn(
'The PyTorch model is in training mode and therefore might'
' not be deterministic. Call the eval() method to set it in'
' evaluation mode if this is not intended.')

def batch_predictions(self, images):
# lazy import
import torch
Expand Down

0 comments on commit 76407ec

Please sign in to comment.