Keras教程
作者: 时海
数据集

一、自带数据集

1、mnist: 手写数字识别数据集

下载地址:https://s3.amazonaws.com/img-datasets/mnist.npz

from keras.datasets import mnist

local_path = '/path/to/mnist.npz'
(x_train, y_train), (x_test, y_test) = mnist.load_data(path=local_path);
print(x_train.shape, y_train.shape, x_test.shape, y_test.shape)
# (60000, 28, 28) (60000,) (10000, 28, 28) (10000,)

如果load_path函数不指定path参数,会默认从上述网址下载数据集到本地

2、IMDB影评情感分类

下载地址:https://s3.amazonaws.com/text-datasets/imdb.npz


# -*- coding: UTF-8 -*-
from keras.datasets import imdb

# 加载数据
local_path = '/path/to/imdb.npz'
(x_train, y_train), (x_test, y_test) = imdb.load_data(path=local_path);
print(x_train.shape, y_train.shape, x_test.shape, y_test.shape)
# (25000,) (25000,) (25000,) (25000,)








一个创业中的苦逼程序员
  • 回复
隐藏