Deep learning 使用多GPU的Pytork/精度太低(10%)
这是火车的一部分。我使用四个GPU进行训练。在我运行5000个历元(批量大小为128)后,准确率为“10%”!!太低了! 以下是测试部分:Deep learning 使用多GPU的Pytork/精度太低(10%),deep-learning,gpu,pytorch,torch,multi-gpu,Deep Learning,Gpu,Pytorch,Torch,Multi Gpu,这是火车的一部分。我使用四个GPU进行训练。在我运行5000个历元(批量大小为128)后,准确率为“10%”!!太低了! 以下是测试部分: if torch.cuda.is_available(): for epoch in range(epoch_num): for i,(images, labels) in enumerate(trainloader): images=images.to(device) labels=labels.to(devic
if torch.cuda.is_available():
for epoch in range(epoch_num):
for i,(images, labels) in enumerate(trainloader):
images=images.to(device)
labels=labels.to(device)
optimizer.zero_grad()
#Forward Backward Optimize
outputs = net(images)
loss = criterion(outputs, labels)
loss.backward()
optimizer.step()
# print statistics
if i%1000==0:
print('Number of epochs: %d, Mini Batch order: %d' %(epoch+1,i))
我不知道出了什么问题,我该如何调查这个问题?这比你使用一个GPU好吗?我在PyTorch方面不是专家,但我认为使用
torch.max
可能会有问题。docu显示值,index=torch.max(张量,1)
,因此您的预期值是输出中具有最大值的值的索引。数据
-您确定这是正确的吗?从理论上讲,可能还有很多其他原因导致不良行为,如不良的超参数、过度拟合。。。此外,使用多个GPU也不应该是问题的原因(因为您使用的GPU少于8个-我想我读过一些关于8个或更多GPU的问题的文章)
with torch.no_grad():
num_correct = 0
total_data = 0
if torch.cuda.is_available():
for images, labels in testloader:
images=images.to(device)
labels=labels.to(device)
output = net(images)
_, expected = torch.max(output.data, 1)
total_data += labels.size(0)
num_correct += (expected == labels).sum().item()