gpt4 book ai didi

python - 尝试下载 MNIST 数据时出现 HTTP 错误

转载 作者:行者123 更新时间:2023-12-03 13:46:32 28 4
gpt4 key购买 nike

我正在使用 Google Colab 使用 Python3 和 PyTorch 1.8 在 MNIST 上训练 LeNet-300-100 全连接神经网络。
要应用转换并下载 MNIST 数据集,将使用以下代码:

# MNIST dataset statistics:
# mean = tensor([0.1307]) & std dev = tensor([0.3081])
mean = np.array([0.1307])
std_dev = np.array([0.3081])

transforms_apply = transforms.Compose([
transforms.ToTensor(),
transforms.Normalize(mean = mean, std = std_dev)
])
这给出了错误:

Downloadinghttp://yann.lecun.com/exdb/mnist/train-images-idx3-ubyte.gz to./data/MNIST/raw/train-images-idx3-ubyte.gz--------------------------------------------------------------------------- HTTPError Traceback (most recent calllast) in ()2 train_dataset = torchvision.datasets.MNIST(3 root = './data', train = True,----> 4 transform = transforms_apply, download = True5 )6

11 frames /usr/lib/python3.7/urllib/request.py inhttp_error_default(self, req, fp, code, msg, hdrs)647 class HTTPDefaultErrorHandler(BaseHandler):648 def http_error_default(self, req, fp, code, msg, hdrs):--> 649 raise HTTPError(req.full_url, code, msg, hdrs, fp)650651 class HTTPRedirectHandler(BaseHandler):

HTTPError: HTTP Error 503: Service Unavailable


怎么了?

最佳答案

我遇到了同样的 503 错误,这对我有用

!wget www.di.ens.fr/~lelarge/MNIST.tar.gz
!tar -zxvf MNIST.tar.gz

from torchvision.datasets import MNIST
from torchvision import transforms

train_set = MNIST('./', download=True,
transform=transforms.Compose([
transforms.ToTensor(),
]), train=True)


test_set = MNIST('./', download=True,
transform=transforms.Compose([
transforms.ToTensor(),
]), train=False)

关于python - 尝试下载 MNIST 数据时出现 HTTP 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66577151/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com