Open davidwang9527 opened 4 years ago
该cell的代码改为如下代码可避免报错: X, y = iter(test_iter).next()
true_labels = d2l.get_fashion_mnist_labels(y.detach().numpy()) pred_labels = d2l.get_fashion_mnist_labels(net(X).argmax(dim=1).detach().numpy()) titles = [true + '\n' + pred for true, pred in zip(true_labels, pred_labels)]
d2l.show_fashion_mnist(X[0:9], titles[0:9])
该cell的代码改为如下代码可避免报错: X, y = iter(test_iter).next()
true_labels = d2l.get_fashion_mnist_labels(y.detach().numpy()) pred_labels = d2l.get_fashion_mnist_labels(net(X).argmax(dim=1).detach().numpy()) titles = [true + '\n' + pred for true, pred in zip(true_labels, pred_labels)]
d2l.show_fashion_mnist(X[0:9], titles[0:9])
嗯,应该是新版本的PyTorch不支持call numpy() on Variable that requires grad了,后续会修正,感谢指出。
是的,我今天也遇到了这样的问题。
bug描述 3.6_softmax-regression-scratch.ipynb "3.6.8 预测"下的cell运行错误: RuntimeError Traceback (most recent call last)