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

How to predict with this model #1

Open
malekiamir opened this issue Nov 10, 2020 · 4 comments
Open

How to predict with this model #1

malekiamir opened this issue Nov 10, 2020 · 4 comments

Comments

@malekiamir
Copy link

Hi
I'm trying to use your model in a digital meter project, and I don't have any experience with PyTorch.
I've trained the model and I can load it but I don't know how to feed the model to predict.
I would be glad if you please help me with this.
Thanks for your great repo

@gustavoplensack
Copy link
Collaborator

Hi @malekiamir!

Consider taking a look at this file, it may help you. There we implement a Pytorch's dataset (docs).

If you need further information, let me know!

@malekiamir
Copy link
Author

malekiamir commented Nov 12, 2020

thanks for your reply @gustavoplensack,
I might describe the problem not very clear. I have the .pth file and the problem is how to use it. I just know that the input shape has 3 dimensions but I don't know what are these dimensions.

so if I have a consumer's usage data in an array for example, and the model is ready. what input should I feed to the model, like model(sth), to get the prediction for that consumer?

@gustavoplensack
Copy link
Collaborator

To evaluate the that for a consumer, your input sth should be in the shape of a 3D tensor. The original input (a time series) is converted into a matrix (2D). The 3D data is built with a binary mask with the same shape as the original data matrix stacked over the original data.

More details about the preprocessing and transformations are provided at section 3.1 and 3.2 of this paper and the code that implements this preprocessing from the download of the original dataset to the input to the model is implemented at:

  • data.py - more precisely at download_data and get_processed_dataset.

  • dataset.py - more precisely at ```FraudDataset``'s constructor.

@malekiamir
Copy link
Author

malekiamir commented Nov 20, 2020

Thanks for your response,

Now I have the output tensor and it is like this :
tensor([[ 0.8610, -1.5230],
[ 2.9618, -2.5590]], device='cuda:0', grad_fn=)
but I don't know how to find the output which is 1 or 0.
The code I am using is this:

for x, y in dataset_train: xnan = x.copy() x[np.isnan(x)] = 0. xnan[~np.isnan(xnan)] = 0. xnan[np.isnan(xnan)] = 1. x = np.stack((x, xnan), axis=1) input = torch.Tensor(x) output = model(input.cuda()) print(output) break

I want to test it on a single object of the dataset but as I said, instead of the classification output, I have The output tensor!

Thanks for your time

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