Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MNIST 데이터셋 가져오기 #3

Closed
sungjk opened this issue Aug 4, 2018 · 2 comments · Fixed by #4
Closed

MNIST 데이터셋 가져오기 #3

sungjk opened this issue Aug 4, 2018 · 2 comments · Fixed by #4

Comments

@sungjk
Copy link
Collaborator

sungjk commented Aug 4, 2018

Problem

3장 분류에서 MNIST 데이터 로딩하는 부분에서 발생하는 에러.
mldata.org 사이트가 다운되어서 데이터를 가져오지 못함.

Solution

데이터 로딩하실 때 아래와 같이 하시면 됩니다.

from shutil import copyfileobj
from six.moves import urllib
from sklearn.datasets.base import get_data_home
import os
import ssl
ssl._create_default_https_context = ssl._create_unverified_context

def fetch_mnist(data_home=None):
    mnist_alternative_url = "https://github.com/amplab/datascience-sp14/raw/master/lab7/mldata/mnist-original.mat"
    data_home = get_data_home(data_home=data_home)
    data_home = os.path.join(data_home, 'mldata')
    if not os.path.exists(data_home):
        os.makedirs(data_home)
    mnist_save_path = os.path.join(data_home, "mnist-original.mat")
    if not os.path.exists(mnist_save_path):
        mnist_url = urllib.request.urlopen(mnist_alternative_url)
        with open(mnist_save_path, "wb") as matlab_file:
            copyfileobj(mnist_url, matlab_file)

fetch_mnist()

from sklearn.datasets import fetch_mldata
mnist = fetch_mldata("MNIST original")
mnist

Reference

scikit-learn/scikit-learn#8588

@gihojeong
Copy link

그렇게 해도 에러가 나는 것은 왜 그럴까요? 여전히 out of index 라는 에러가 발생합니다.

@sungjk
Copy link
Collaborator Author

sungjk commented Aug 6, 2018

@gihojeong 작성하신 코드와 발생한 에러 내용을 첨부해주실 수 있나요?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants