예제 #1
0
def run():
    pt = Preprocessor()
    tr = Trainer()
    X_train, y_train = pt.load_data()
    X_test, y_test = pt.load_data("mnist_test_data.npz")

    x1 = X_train.reshape((-1, 28, 28, 1))
    x2 = X_test.reshape((-1, 28, 28, 1))

    y1 = keras.utils.to_categorical(y_train, len(np.unique(y_train)))
    y2 = keras.utils.to_categorical(y_test, len(np.unique(y_test)))

    clf = tr.cnn(x1, y1, x2, y2)
    tr.save(clf, "cnn_mnist_keras.h5")
    return clf
예제 #2
0
def run():
    pt = Preprocessor()
    tr = Trainer()
    ts = Tester()
    t0 = time.time()
    X_train, y_train = pt.load_data()
    X_test, y_test = pt.load_data("mnist_test_data.npz")

    X_train, y_train = make_shuffle(X_train, y_train)
    X_test, y_test = make_shuffle(X_test, y_test)

    X_train = X_train.reshape((-1, 1, 28, 28))
    X_test = X_test.reshape((-1, 1, 28, 28))
    print(time.time() - t0)
    t1 = time.time()
    clf = tr.net(X_train, y_train)
    print(time.time() - t1)
    acc = ts.get_acc(clf, X_test, y_test)  #acc=97.8%

    return clf, acc