Bug in Example Code

Hi, I’ve been using the Jetson Nano AI Fundamentals course. I encountered a problem that the saved models do not work after reload. I searched the forum and found this post (Loading a trained model doesn't appear to work as expected), but it doesn’t really provide the right answer.

After additional research by reading the pyTorch tutorial, I found that the example Jupyter notebooks have bugs in the load function. According to the pyTorch tutorial, there must be a model.eval() right after the load function to make the loaded model work (I can’t post a section link, but you can find the pytorch page by googling “pytorch load model”). This is missing from the example code in Jupyter. I added model.eval() into the load function and the problem is solved. I wanted to leave a post here so that other people can find it if they run into the same trouble again. Meanwhile, can you please work with the code owners to correct the Jupyter notebooks?


We are moving this post to the Jetson Nano forum to get better help.

Thank you.


There are several courses in the Jetson AI Fundamentals:


Would you mind telling us which course you take?

Hi, I ran into the problem with s1e3 and s1e4. Regression and classification.



Thanks for the information.

Is the output incorrect or is the inference not working?

We try the jetbot/live_demo.ipynb at master · NVIDIA-AI-IOT/jetbot · GitHub sample with some dummy input.

The sample can work with or without calling model.eval().
For example:

import torch
import torchvision
import numpy as np

model = torchvision.models.alexnet(pretrained=False)
model.classifier[6] = torch.nn.Linear(model.classifier[6].in_features, 2)


device = torch.device('cuda')
model = model.to(device)

x = torch.tensor(np.zeros((1,3,224,224)), dtype=torch.float).to(device)
y = model(x)


Not the jetbot version. It’s the ai fundamental package. There’s a classification notebook and a regression notebook. They have a load function as a callback after clicking the load button. The eval() is missing from there and the load doesn’t work.



Thanks for the information.
We will check it and let you know the following.


There is no update from you for a period, assuming this is not an issue any more.
Hence we are closing this topic. If need further support, please open a new one.


Thanks for your patience.

We have lots of versions for that container.
Could you also share which version(tag) of the dli-nano-ai container you use?