-
Notifications
You must be signed in to change notification settings - Fork 248
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
value error #2
Comments
For which notebook is this? Only the first 3 notebooks should be considered complete, the rest are in the process of being re-written. The model should return a tuple of tensors, in the first three we are returning both the final output and an intermediate layer so we can plot it with PCA/t-SNE. The error you are getting is due to the model only returning a single tensor, i.e. your model's |
I have executed the resnet.ipynb file with my own dataset. The model has run successfully but I want to visualize the predicted labels as well as confusion matrix as it is shown in the "Lenet.ipynb" tutorial. So, whenever I am trying to execute "images, labels, probs = get_predictions(model, test_iterator)" this line of code it is throwing error like this, in get_predictions(model, iterator) ValueError: too many values to unpack (expected 2) |
In the ResNet model, change the last few lines of the h = out.view(out.shape[0], -1)
out = self.fc(h)
return out, h |
changing these line of code is throwing another error |
Can you upload the notebook to a GitHub gist? I'll have a quick look at it. |
I have uploaded the notebook as a Github gist.
…On Mon, Apr 6, 2020 at 7:38 PM Ben Trevett ***@***.***> wrote:
Can you upload the notebook to a GitHub gist? I'll have a quick look at it.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#2 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AL4XZOCYAEZLKAVTRREVXBLRLHO5TANCNFSM4MBF7VZQ>
.
--
With Regards,
Rukhmini Roy
|
In the In both the out = out.view(out.shape[0], -1)
out = self.fc(out)
return out to h = out.view(out.shape[0], -1)
out = self.fc(h)
return out, h |
Thanks for all the help Ben, but still I am getting the same runtime error
while using test iterator.
…On Mon, Apr 6, 2020 at 9:41 PM Ben Trevett ***@***.***> wrote:
In the train and evaluate functions you need to change fx = model(x) to fx,
_ = model(x).
In both the ResNet18 and ResNet34 models, within the forward method you
need to change:
out = out.view(out.shape[0], -1)
out = self.fc(out)return out
to
h = out.view(out.shape[0], -1)
out = self.fc(h)return out, h
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#2 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AL4XZODYZY4TEFUQ7C2ESRDRLH5J3ANCNFSM4MBF7VZQ>
.
--
With Regards,
Rukhmini Roy
|
https://gist.github.com/bentrevett/3f899ce17781d91e8c9dbdad2c1a1cc9 Here is the code for the AlexNet notebook but with the model changed to ResNet18 - might be useful for you. |
This also throwing the same runtime error. I am using gray scale images to
train and test the network. Will that be a problem?
…On Mon, Apr 6, 2020 at 11:40 PM Ben Trevett ***@***.***> wrote:
https://gist.github.com/bentrevett/3f899ce17781d91e8c9dbdad2c1a1cc9
Here is the code for the AlexNet notebook but with the model changed to
ResNet18 - might be useful for you.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#2 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AL4XZOE3UH2FAG5K5ZHJ373RLILKDANCNFSM4MBF7VZQ>
.
--
With Regards,
Rukhmini Roy
|
hello,
Whenever I am trying to run with iterator it is showing error
ValueError Traceback (most recent call last)
in ()
7 start_time = time.time()
8
----> 9 train_loss, train_acc = train(model, train_iterator, optimizer, criterion, device)
10 valid_loss, valid_acc = evaluate(model, valid_iterator, criterion, device)
11
in train(model, iterator, optimizer, criterion, device)
13 optimizer.zero_grad()
14
---> 15 y_pred, _ = model(x)
16
17 loss = criterion(y_pred, y)
ValueError: too many values to unpack (expected 2)
The text was updated successfully, but these errors were encountered: