Comments (6)
@NomiMalik0207 You need to debug line by line, especially I suggest you to look tensor sizes. In my experience, when the accuracy is above 1.0, it was (mostly) due to the wrong processed tensors. I always check the tensor sizes for this reason.
Also, this is not related to cutmix technically, but I will open this for now to help you. Let me know the result after you debug.
from cutmix.
you can change predicted vector to one hot [64, 7]. or you should check the prediction accuracy only on validation set which would have target size [64]. If codes are provided, it will be much easier to answer. Thanks.
from cutmix.
i solved this error by matching the size but now in while testing model, the accuracy of test set start from 1200 or above out of 100. the code for test set is
for batch_idx, (inputs, targets) in enumerate(Testloader):
bs, ncrops, c, h, w = np.shape(inputs)
inputs = inputs.view(-1, c, h, w)
if use_cuda:
inputs, targets = inputs.cuda(), targets.cuda()
inputs, targets = Variable(inputs, volatile=True), Variable(targets)
outputs = net(inputs)
outputs_avg = outputs.view(bs, ncrops, -1).mean(1)
loss = criterion(outputs_avg, targets)
Test_loss += loss.item()
_, predicted = torch.max(outputs_avg.data, 1)
predicted= predicted.unsqueeze(1) // for matchin size
total += targets.size(0)
correct += predicted.eq(targets.long().data).cpu().sum()// target should be long tensor
utils.progress_bar(batch_idx, len(Testloader), 'Loss: %.3f | Acc: %.3f%% (%d/%d)'
% (Test_loss / (batch_idx + 1), 100. * correct / total, correct, total))
from cutmix.
@NomiMalik0207 Don't use CutMix wrapper for Testloader. Seems to me, predicted= predicted.unsqueeze(1)
is not the solution for you.
- Remove CutMix wrapper for Testloader, not Trainloader.
- no .unsqueeze(1). Use torch.argmax to get predicted class indices and count the number of correctness with targets.
I hope this will help you.
from cutmix.
HERE is the results of your suggested modification
- i already didnot use CutMix wrapper for testloader, So i removed predicted= predicted.unsqueeze(1) from testing solved the problem.
- when i use torch.agrmax with trainloader, the train accuracy started from more then 100%. but its going normal with unsqueeze.
Seeing farward to your helpful suggestions .
Thank you mate
from cutmix.
Thank you for your time and help.
Here i showed the training loop for my network. The size of tensors are given as comment at the end of line.
for batch_idx, (inputs, targets) in enumerate(trainloader):
import pdb
if use_cuda:
inputs, targets = inputs.cuda(), targets.cuda()
inputs, targets = Variable(inputs, volatile=True), Variable(targets)
optimizer.zero_grad()
outputs = net(inputs)
loss = criterion(outputs, targets)
train_loss += loss.item()
pdb.set_trace()
_, predicted = torch.max(outputs.data, 1)// predicted.size()=torch.Size([64])
total += targets.size(0)
predicted = torch.argmax(predicted)//predicted.size()=torch.Size([])
// here when i print the value of predcted, it shows predicted= tensor(38)
#predicted= predicted.unsqueeze(1)// if i use this line, this shows //predicted.size()=torch.Size([64, 1])
correct += predicted.eq(targets.long().data).cpu().sum()// targets.size()=torch.Size([64, 7])
loss.backward()
optimizer.step()
from cutmix.
Related Issues (8)
- Getting empty dataset on using Cutmix Dataloader
- RuntimeError: element 0 of tensors does not require grad and does not have a grad_fn
- The meaning of num_mix HOT 2
- Resnet-18 model download link is broken? HOT 1
- Reproducibility on Resnet-110 on Cifar-100
- 'CutMix' object is not callable
- CutMix function
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cutmix.