def load_train_data(): util.download_and_extract( "./dataset/MNIST", "http://deeplearning.net/data/mnist/mnist.pkl.gz") train, valid, test = util.unpickle("./dataset/MNIST/mnist.pkl") X_train = np.concatenate([train[0], valid[0]]).reshape([-1, 28, 28]) Y_train = np.concatenate([train[1], valid[1]]).T return X_train, Y_train, util.class_encoding(Y_train)
def load_test_data(): util.download_and_extract( "./dataset/MNIST", "http://deeplearning.net/data/mnist/mnist.pkl.gz") train, valid, test = util.unpickle("./dataset/MNIST/mnist.pkl") X_test = test[0].reshape([-1, 28, 28]) Y_test = test[1].T return X_test, Y_test, util.class_encoding(Y_test)
def load_test_data(): util.download_and_extract( "./dataset/CIFAR-10", "https://www.cs.toronto.edu/~kriz/cifar-10-python.tar.gz") data_dict = util.unpickle( "./dataset/CIFAR-10/cifar-10-batches-py/test_batch") X_test = (np.array(data_dict[b'data'], dtype=float) / 255.0).reshape( [-1, 3, 32, 32]).transpose([0, 2, 3, 1]) Y_test = np.array(data_dict[b'labels'], dtype=int) return X_test, Y_test, util.class_encoding(Y_test)
def load_train_data(): util.kaggle_and_extract("./dataset/FRUITS", "moltean/fruits") keys = [ str(x) for x in sorted( Path('./dataset/FRUITS/fruits-360/Training').glob('*')) ] X_train = np.asarray( sorted(Path('./dataset/FRUITS/fruits-360/Training').glob("**/*.jpg"))) Y_train = np.asarray( [keys.index('/'.join(str(x).split('/')[:-1])) for x in X_train]) return X_train, Y_train, util.class_encoding(Y_train)
def load_train_data(): util.download_and_extract( "./dataset/CIFAR-10", "https://www.cs.toronto.edu/~kriz/cifar-10-python.tar.gz") X_train = np.zeros(shape=[50000, 32, 32, 3], dtype=float) Y_train = np.zeros(shape=[50000], dtype=int) begin = 0 for i in range(1, 6): data_dict = util.unpickle( "./dataset/CIFAR-10/cifar-10-batches-py/data_batch_{}".format(i)) x_raw = (np.array(data_dict[b'data'], dtype=float) / 255.0).reshape( [-1, 3, 32, 32]).transpose([0, 2, 3, 1]) y_raw = np.array(data_dict[b'labels'], dtype=int) num = len(x_raw) end = begin + num X_train[begin:end, :] = x_raw Y_train[begin:end] = y_raw begin = end return X_train, Y_train, util.class_encoding(Y_train)
def load_test_data(): util.kaggle_and_extract("./dataset/IRIS", "uciml/iris") raw = list(csv.reader(open('./dataset/IRIS/Iris.csv', 'r')))[1:] X_test = np.asarray([np.asarray([x for x in r[:-1]]) for r in raw]) Y_test = np.asarray([np.asarray(get_key(r[-1])) for r in raw]) return X_test, Y_test, util.class_encoding(Y_test)