Error: The `preds` should be probabilities, but values were detected outside of [0,1] range.
kfarivar opened this issue · 2 comments
I don't see any softmax used on the output, so I get this error when testing (and training) the pretrained network.
python train.py --test_phase 1 --pretrained 1 --classifier resnet18
The `preds` should be probabilities, but values were detected outside of [0,1] range.
which is a reasonable error. :)
this is the part of code that is problematic:
Line 44 in 7a6e1f9
what function should be used on the output of the model ?, softmax?
why is this not in your codes ?
Originally posted by @kfarivar in #12 (comment)
I am just facing this issue. I got around by downgrading and using the same version used of pytorch-lightning==1.1.0
.
However, that caused also a problem of compatibility with torchtext
. And I also tried to solve that by downgrading that as well torchtext==0.8.1
. However, no resolution after that.
I am running the following
!python train.py --gpu_id=0 --data_dir='datasets' --classifier vgg11_bn
And getting
Traceback (most recent call last):
File "train.py", line 5, in <module>
from pytorch_lightning import Trainer, seed_everything
File "/usr/local/lib/python3.7/dist-packages/pytorch_lightning/__init__.py", line 60, in <module>
from pytorch_lightning import metrics
File "/usr/local/lib/python3.7/dist-packages/pytorch_lightning/metrics/__init__.py", line 14, in <module>
from pytorch_lightning.metrics.metric import Metric
File "/usr/local/lib/python3.7/dist-packages/pytorch_lightning/metrics/metric.py", line 23, in <module>
from pytorch_lightning.metrics.utils import _flatten, dim_zero_cat, dim_zero_mean, dim_zero_sum
File "/usr/local/lib/python3.7/dist-packages/pytorch_lightning/metrics/utils.py", line 18, in <module>
from pytorch_lightning.utilities import rank_zero_warn
File "/usr/local/lib/python3.7/dist-packages/pytorch_lightning/utilities/__init__.py", line 24, in <module>
from pytorch_lightning.utilities.apply_func import move_data_to_device
File "/usr/local/lib/python3.7/dist-packages/pytorch_lightning/utilities/apply_func.py", line 25, in <module>
from torchtext.data import Batch
File "/usr/local/lib/python3.7/dist-packages/torchtext/__init__.py", line 40, in <module>
_init_extension()
File "/usr/local/lib/python3.7/dist-packages/torchtext/__init__.py", line 36, in _init_extension
torch.ops.load_library(ext_specs.origin)
File "/usr/local/lib/python3.7/dist-packages/torch/_ops.py", line 104, in load_library
ctypes.CDLL(path)
File "/usr/lib/python3.7/ctypes/__init__.py", line 364, in __init__
self._handle = _dlopen(self._name, mode)
OSError: /usr/local/lib/python3.7/dist-packages/torchtext/_torchtext.so: undefined symbol: _ZNK3c104Type14isSubtypeOfExtESt10shared_ptrIS0_EPSo
I modified the code in the CIFAR10Module like:
def forward(self, batch):
images, labels = batch
outputs = self.model(images)
_, predictions = torch.max(outputs, 1)
loss = self.criterion(outputs, labels)
accuracy = self.accuracy(predictions, labels)
return loss, accuracy * 100
and it seems to have solved the problem.