python奇奇怪怪的特点

除法奇怪的特点

    print('test  %d epoch loss: %.3f  acc: %.3f ' % (epoch + 1, test_loss, 100 * correct // test_total))
# 很奇怪,明明直接打印的时候,除法用/就可以了,但这里面非要用两个斜杠//

调用GPU的神奇的方法们

use_gpu = torch.cuda.is_available()
if use_gpu:
    net = net.cuda()
print(net)

使用以上代码就可以调用了,然后为了把所有的数据都放到GPU中运算,需要进行如下操作:

inputs, labels = Variable(inputs.cuda()), Variable(train_labels.cuda())

猜你喜欢

转载自blog.csdn.net/huatianxue/article/details/108302533