Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wuziqiqiqi opened this issue Sep 26, 2022 · 1 comment
Open

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

wuziqiqiqi opened this issue Sep 26, 2022 · 1 comment

Comments

@wuziqiqiqi
Copy link

wuziqiqiqi commented Sep 26, 2022

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
Copy link
Member

xuyxu commented Jan 4, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants