-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathusage.py
More file actions
42 lines (24 loc) · 708 Bytes
/
usage.py
File metadata and controls
42 lines (24 loc) · 708 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#-*- coding:utf-8 -*-
from tensorflow.examples.tutorials.mnist import input_data
from matplotlib import pyplot as plt
import numpy as np
from sklearn.decomposition import PCA
#from nca_naive import NCA
#from nca_matrix import NCA
#from nca_fast import NCA
from nca_scipy import NCA
mnist = input_data.read_data_sets("/home/lxcnju/workspace/datasets/mnist/")
num = 1000
pca = PCA(n_components = 100)
X = mnist.train.images[0 : num]
Y = mnist.train.labels[0 : num]
uni_Y = np.unique(Y)
X = pca.fit_transform(X)
print("Beigin...")
print(X.shape)
print(Y.shape)
print(uni_Y)
nca = NCA(low_dims = 10, optimizer = 'cd', learning_rate = 0.01)
nca.fit(X, Y)
low_x = nca.transform(X)
print("Done!")