TorchEnsemble-Community / Ensemble-Pytorch

A unified ensemble framework for PyTorch to improve the performance and robustness of your deep learning model.
https://ensemble-pytorch.readthedocs.io
BSD 3-Clause "New" or "Revised" License
1.08k stars 95 forks source link

need to generate prediction. model.predict not working #129

Open wuziqiqiqi opened 2 years ago

wuziqiqiqi commented 2 years ago

Hi there, After the model is trained, I need to use the model to generate predictions with my test dataset, instead of just getting a single accuracy (so eval() won't be enough). However, the model.predict did not work. If I do model.predict(test_loader), it gives an error:

ValueError: The type of input X should be one of {{torch.Tensor, np.ndarray}}.

if I do model.predict(*test_loader) it gives an error:

[/usr/local/lib/python3.7/dist-packages/torch/nn/modules/module.py](https://localhost:8080/#) in _call_impl(self, *input, **kwargs)
   1128         if not (self._backward_hooks or self._forward_hooks or self._forward_pre_hooks or _global_backward_hooks
   1129                 or _global_forward_hooks or _global_forward_pre_hooks):
-> 1130             return forward_call(*input, **kwargs)
   1131         # Do not call functions when jit is used
   1132         full_backward_hooks, non_full_backward_hooks = [], []

TypeError: forward() takes 2 positional arguments but 191 were given
xuyxu commented 1 year ago

Hi @wuziqiqiqi, @singhabhinav, predict accepts a tensor instead of a data loader as the input.