コード例 #1
0
        display.save(res,70,80,folder='./imgs_pie',name='out',index=i)

if(int(options.classifier)):
    train = np.loadtxt("../datasets/multi_pie_train.dat")
    l_train = np.loadtxt("../datasets/multi_pie_l_train.dat")
    test = np.loadtxt("../datasets/multi_pie_test.dat")
    l_test = np.loadtxt("../datasets/multi_pie_l_test.dat")

    train = train+abs(np.min(train))
    train = train/np.max(train)
    train = train.astype("float32")

    test = test+abs(np.min(test))
    test = test/np.max(test)
    test = test.astype("float32")
    
    h = auto.get_hidden(np.asarray(train),session=session)
    k = knn_classifier.knn_classifier(data=h,label=l_train,k=3)
    #k =  knn_classifier.knn_classifier(data=train,label=l_train,k=3)
    k.learn()

    

    t = auto.get_hidden(np.asarray(test),session=session)
    
    print k.accuracy(t,l_test)
    print zip(k.predict(t),l_test)
    #print k.accuracy(test,l_test)

コード例 #2
0
    display.display(c,28,28)
m = np.mean(data[:500],axis=0)

c = np.matmul((b+v),w)

'''
#display.display(c,28,28)
#display.display(np.ndarray.flatten(np.array(m)),28,28)

if(int(options.save)):
    for i in range(50):
        display.save(data[i],28,28,folder='./imgs',name='in',index=i)
    
        res = auto.get_output(np.asarray([data[i]]),session=session)
        #if(options.normed):
         #   res = res + np.cumsum(data,axis=0)[-1]/data.shape[0]
        display.save(res,28,28,folder='./imgs',name='out',index=i)

if(int(options.classifier)):
    h = auto.get_hidden(np.asarray(data),session=session)
    k = knn_classifier.knn_classifier(data=h,label=lab,k=3)
    k.learn()

    test, labtest = get_data_from_minst.get_test_from_mnist()

    t = auto.get_hidden(np.asarray(test),session=session)
    
    print k.accuracy(t,labtest)