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

Code samples contain errors and is missing a function #96

Closed
krisbock opened this issue Dec 31, 2022 · 2 comments
Closed

Code samples contain errors and is missing a function #96

krisbock opened this issue Dec 31, 2022 · 2 comments
Assignees

Comments

@krisbock
Copy link

Copying the code snippets into a file and executing doesn't work, as the testAccuracy function doesn't test for GPU. So if you are using a GPU and the train function loads the train dataset/model weights onto the GPU, you receive the following error:

RuntimeError: Input type (torch.FloatTensor) and weight type (torch.cuda.FloatTensor) should be the same or input should be a MKLDNN tensor and weight is a dense tensor

Fixing this by adding the following:

images, labels = images.to(device), labels.to(device)

to the testAccuracy function after "images, labels = data"

In addition, the main method calls a testModelAccuracy function that doesn't exist. From the code sample referenced in GitHub (https://github.com/microsoft/Windows-Machine-Learning/blob/master/Samples/Tutorial%20Samples/PyTorch%20Image%20Classification/PyTorchTraining%20-%20Image%20Classification/PyTorchTraining.py), it appears a testClasses function is required.


Document Details

Do not edit this section. It is required for learn.microsoft.com ➟ GitHub issue linking.

@wizardpisces
Copy link

Problem still exist, any progress?

@QuinnRadich
Copy link
Contributor

Closing out these old issues - the pages themselves have been long since changed, and the initial issue should have been resolved (though it was never logged here).

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

3 participants