提交 792875e3 编写于 作者: Y Yu Yang

Lazy initialize mnist dataset.

Fix unittest
上级 cbcd53af
......@@ -16,18 +16,29 @@ def __mnist_reader_creator__(data, target):
TEST_SIZE = 10000
X_train = None
X_test = None
y_train = None
y_test = None
data = sklearn.datasets.mldata.fetch_mldata(
"MNIST original", data_home=DATA_HOME)
X_train, X_test, y_train, y_test = sklearn.model_selection.train_test_split(
data.data, data.target, test_size=TEST_SIZE, random_state=0)
def __initialize_dataset__():
global X_train, X_test, y_train, y_test
if X_train is not None:
return
data = sklearn.datasets.mldata.fetch_mldata(
"MNIST original", data_home=DATA_HOME)
X_train, X_test, y_train, y_test = sklearn.model_selection.train_test_split(
data.data, data.target, test_size=TEST_SIZE, random_state=0)
def train_creator():
__initialize_dataset__()
return __mnist_reader_creator__(X_train, y_train)
def test_creator():
__initialize_dataset__()
return __mnist_reader_creator__(X_test, y_test)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册