Beispiel #1
0
def rbm_visual_weights(X_train, y_train, X_test, y_test):

    rbm = test_rbm(X_train, y_train, X_test, y_test, \
                   max_iter=5000, verbose=True)
       
    pl.figure(figsize=(50,50))

    W = rbm.W.T
    print W.shape

    for i,w in enumerate(W):
        w = (np.array(w) - np.mean(w)) / (len(w) * np.var(w))
        pl.subplot(10, 10, i+1)
        pl.imshow( w.reshape( (29,29) ) )
        if not (i%50): print '.',

    pl.show()
    return
Beispiel #2
0
    if sys.argv[1] == '-nt':

        X_train, y_train, X_test, y_test = input_data("./data/", test_samples=[7,8])

        test_ann(X_train, y_train, X_test, y_test, [X_train.shape[1], 30, y_train.shape[1]])


    elif sys.argv[1] == '-nv':

        X_train, y_train, X_test, y_test = input_data("./data/", test_samples=[7,8])

        ann_visual_weights(X_train, y_train, X_test, y_test)


    elif sys.argv[1] == '-rt':

        X_train, y_train, X_test, y_test = input_data("./data/", test_samples=[])

        test_rbm( X_train, y_train, X_test, y_test)


    elif sys.argv[1] == '-rv':

        X_train, y_train, X_test, y_test = input_data("./data/", test_samples=[])

        rbm_visual_weights(X_train, y_train, X_test, y_test)


    else: print 'incorrect console argument'