Exemplo n.º 1
0
for j in range(8):
    z[hid[j]] = v[hid[j]]
    c = np.matmul(z,w)
    z = np.zeros(60)
    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)
    
Exemplo n.º 2
0
hid = [0,1,27,28,39,45,52,53]

for j in range(8):
    z[hid[j]] = v[hid[j]]
    c = np.matmul(z,w)
    z = np.zeros(60)
    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],70,80,folder='./imgs_pie',name='in',index=i)
    
        res = auto.get_output(np.asarray([data[i]]),session=session)

        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")
Exemplo n.º 3
0
act = ['tanh','tanh','tanh']
act2 = ['linear','linear','linear']
auto = autoencoder(units,act)

auto.generate_encoder(euris=True)
auto.generate_decoder(symmetric=False,act=act2)

session = auto.init_network()

#bat = batch.rand_batch(data,70)

ic,bc = auto.train(data,batch=None,n_iters=5000,use_dropout=False,keep_prob=0.5,reg_weight=False,reg_lambda=0.0,model_name='conv_7.mod',display=False,noise=False,gradient='adam',learning_rate=0.000125)


print "Finished. Initial cost: ",ic," Final cost: ",bc

auto.load_model('conv_7.mod',session=session)
#data = data+m
auto.stop_dropout()
red_feat = auto.get_hidden(data,session=session)
out_feat = auto.get_output(data,session=session)
np.savetxt("red_7",red_feat)
np.savetxt("out_7",out_feat)

nd = np.transpose(data)
no = np.transpose(out_feat)
if(sys.argv[1]=='s'):
    for i in range(64):
        #display.save(nd[i],3,3,3,folder='./feat',name='in_12',index=i)
        display.save(no[i],3,3,3,folder='./feat',name='out_7',index=i)