We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 6f33ebe commit 12a70feCopy full SHA for 12a70fe
nearest_neighbor.py
@@ -12,14 +12,13 @@
12
Xtr, Ytr = mnist.train.next_batch(5000) #5000 for training (nn candidates)
13
Xte, Yte = mnist.test.next_batch(200) #200 for testing
14
15
+#Reshape images to 1D
16
Xtr = np.reshape(Xtr, newshape=(-1, 28*28))
17
Xte = np.reshape(Xte, newshape=(-1, 28*28))
18
19
xtr = tf.placeholder("float", [None, 784])
20
xte = tf.placeholder("float", [784])
21
-nn = tf.Variable(tf.zeros([10]))
22
-
23
#Calculation of L1 Distance
24
distance = tf.reduce_sum(tf.abs(tf.add(xtr, tf.neg(xte))), reduction_indices=1)
25
#Predict: Get min distance index (Nearest neighbor)
0 commit comments