작성
·
32
0
밑바닥부터 시작하는 딥러닝 책 1권, 3.6 손글씨 숫자 인식 부분을 주피터 노트북으로 따라하고 있습니다
딥러닝 파일에서 따라 하고 있고 mnist 데이터 셋을 이렇게 저장해서 아래와 같이 실행했습니다.
import sys,os
sys.path.append(os.pardir)
from mnist import load_mnist
(x_train,t_train),(x_test,t_test) = load_mnist(flatten=True,normalize=False)
print(x_train.shape)
print(t_train.shape)
print(x_test.shape)
print(t_test.shape)
이런 식으로 입력했고 아래와 같은 오류가 떴습니다.
Downloading train-images-idx3-ubyte.gz ...
---------------------------------------------------------------------------
HTTPError Traceback (most recent call last)
/var/folders/79/d4_6x4wx1xnfg9kn_7_km__h0000gn/T/ipykernel_8179/3746115192.py in <module>
3 from mnist import load_mnist
4
----> 5 (x_train,t_train),(x_test,t_test) = load_mnist(flatten=True,normalize=False)
6
7 print(x_train.shape)
~/mnist.py in load_mnist(normalize, flatten, one_hot_label)
~/mnist.py in init_mnist()
~/mnist.py in download_mnist()
~/mnist.py in _download(file_name)
~/opt/anaconda3/lib/python3.9/urllib/request.py in urlretrieve(url, filename, reporthook, data)
237 url_type, path = _splittype(url)
238
--> 239 with contextlib.closing(urlopen(url, data)) as fp:
240 headers = fp.info()
241
~/opt/anaconda3/lib/python3.9/urllib/request.py in urlopen(url, data, timeout, cafile, capath, cadefault, context)
212 else:
213 opener = _opener
--> 214 return opener.open(url, data, timeout)
215
216 def install_opener(opener):
~/opt/anaconda3/lib/python3.9/urllib/request.py in open(self, fullurl, data, timeout)
521 for processor in self.process_response.get(protocol, []):
522 meth = getattr(processor, meth_name)
--> 523 response = meth(req, response)
524
525 return response
~/opt/anaconda3/lib/python3.9/urllib/request.py in http_response(self, request, response)
630 # request was successfully received, understood, and accepted.
631 if not (200 <= code < 300):
--> 632 response = self.parent.error(
633 'http', request, response, code, msg, hdrs)
634
~/opt/anaconda3/lib/python3.9/urllib/request.py in error(self, proto, *args)
553 http_err = 0
554 args = (dict, proto, meth_name) + args
--> 555 result = self._call_chain(*args)
556 if result:
557 return result
~/opt/anaconda3/lib/python3.9/urllib/request.py in _call_chain(self, chain, kind, meth_name, *args)
492 for handler in handlers:
493 func = getattr(handler, meth_name)
--> 494 result = func(*args)
495 if result is not None:
496 return result
~/opt/anaconda3/lib/python3.9/urllib/request.py in http_error_302(self, req, fp, code, msg, headers)
745 fp.close()
746
--> 747 return self.parent.open(new, timeout=req.timeout)
748
749 http_error_301 = http_error_303 = http_error_307 = http_error_302
~/opt/anaconda3/lib/python3.9/urllib/request.py in open(self, fullurl, data, timeout)
521 for processor in self.process_response.get(protocol, []):
522 meth = getattr(processor, meth_name)
--> 523 response = meth(req, response)
524
525 return response
~/opt/anaconda3/lib/python3.9/urllib/request.py in http_response(self, request, response)
630 # request was successfully received, understood, and accepted.
631 if not (200 <= code < 300):
--> 632 response = self.parent.error(
633 'http', request, response, code, msg, hdrs)
634
~/opt/anaconda3/lib/python3.9/urllib/request.py in error(self, proto, *args)
559 if http_err:
560 args = (dict, 'default', 'http_error_default') + orig_args
--> 561 return self._call_chain(*args)
562
563 # XXX probably also want an abstract factory that knows when it makes
~/opt/anaconda3/lib/python3.9/urllib/request.py in _call_chain(self, chain, kind, meth_name, *args)
492 for handler in handlers:
493 func = getattr(handler, meth_name)
--> 494 result = func(*args)
495 if result is not None:
496 return result
~/opt/anaconda3/lib/python3.9/urllib/request.py in http_error_default(self, req, fp, code, msg, hdrs)
639 class HTTPDefaultErrorHandler(BaseHandler):
640 def http_error_default(self, req, fp, code, msg, hdrs):
--> 641 raise HTTPError(req.full_url, code, msg, hdrs, fp)
642
643 class HTTPRedirectHandler(BaseHandler):
HTTPError: HTTP Error 403: Forbidden
인터넷을 찾아보면 권한 수락 오류라고 뜨기도 하는데 어떻게 해결해야할 지 모르겠습니다. 도움주시면 감사하겠습니다.
답변 1
0
안녕하세요, 인프런 AI 인턴입니다.
아아어어님, 주피터 노트북에서 MNIST 데이터를 가져오는 중 HTTP Error 403가 발생했다면, 이는 데이터셋을 다운로드하려는 과정에서 권한 문제로 인해 접근이 차단된 것입니다. 이 문제를 해결하기 위해 다음과 같은 방법을 시도해 보세요.
VPN을 사용해서 시도하기: 때때로 다운로드 서버가 특정 지역의 접근을 차단하기도 합니다. VPN을 사용하여 다른 지역의 IP로 연결한 후 시도해보세요.
대체 데이터셋 소스 사용하기: 다운로드 URL에 접근이 불가능할 경우, 다른 경로를 통해 MNIST 데이터를 다운로드 받은 후 직접 불러오는 방법도 있습니다. 예를 들어, 데이터셋을 Kaggle에서 다운로드하여 사용해 보세요.
저장 경로 확인하기: 데이터가 이미 다운로드된 경우 올바른 경로에 저장되어 있는지 확인하고, 그 경로를 사용해 데이터를 불러올 수 있도록 설정해주세요.
이 방법들 중 하나가 도움이 되길 바랍니다. 추가로 질문이 있으시면 언제든지 문의해 주세요. 감사합니다.