Skip to content

Commit 43b8202

Browse files
author
Vineet John
committed
Completed testing and results for CNN. Added bash script entry for CNN
1 parent fed0ee1 commit 43b8202

File tree

4 files changed

+34
-9
lines changed

4 files changed

+34
-9
lines changed

assignments/a5/a5.tex

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,29 @@
3232
\section{Tensorflow - MNIST} % (fold)
3333
\label{sec:tensorflow_mnist}
3434

35+
\subsection{Softmax vs. CNN vs. Fully Connected} % (fold)
36+
\label{sub:softmax_vs_cnn_vs_fully_connected}
37+
38+
CNN was run for 1000 iterations.
39+
40+
\begin{table}[th]
41+
\centering
42+
\begin{tabular}{| l | r |}
43+
\hline
44+
\textbf{Neural Net Type} & \textbf{Accuracy} \\
45+
\hline
46+
\hline
47+
Softmax Regression & 0.9205 \\
48+
\hline
49+
Convolutional Neural Network & 0.9664 \\
50+
\hline
51+
\end{tabular}
52+
\caption{Accuracy Comparisons - I}
53+
\label{tab:accuracy_comparisons_i}
54+
\end{table}
55+
56+
% subsection softmax_vs_cnn_vs_fully_connected (end)
57+
3558
% section tensorflow_mnist (end)
3659

3760

tensorflow-mnist/processors/cnn_processor.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,10 @@ def process(self):
6060
if i % 100 == 0:
6161
train_accuracy = accuracy.eval(feed_dict={
6262
x: batch[0], y_: batch[1], keep_prob: 1.0})
63-
print("step %d, training accuracy %g" % (i, train_accuracy))
63+
log.info("step %d, training accuracy %g" % (i, train_accuracy))
6464
train_step.run(feed_dict={x: batch[0], y_: batch[1], keep_prob: 0.5})
6565

66-
print("test accuracy %g" % accuracy.eval(feed_dict={
66+
log.info("test accuracy %g" % accuracy.eval(feed_dict={
6767
x: mnist.test.images, y_: mnist.test.labels, keep_prob: 1.0}))
6868

6969
log.info("CNNProcessor concluded")

tensorflow-mnist/processors/softmax_regression_processor.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
from processors.processor import Processor
55
from utils import log_helper
66

7-
log = log_helper.get_logger("CNNProcessor")
7+
log = log_helper.get_logger("SoftmaxRegressionProcessor")
88

99

1010
class SoftmaxRegressionProcessor(Processor):
1111

1212
def process(self):
13-
log.info("CNNProcessor begun")
13+
log.info("SoftmaxRegressionProcessor begun")
1414

1515
# Import data
1616
data_dir = "/tmp/tensorflow/mnist/input_data"
@@ -39,7 +39,6 @@ def process(self):
3939
# Test trained model
4040
correct_prediction = tf.equal(tf.argmax(y, 1), tf.argmax(y_, 1))
4141
accuracy = tf.reduce_mean(tf.cast(correct_prediction, tf.float32))
42-
print(sess.run(accuracy, feed_dict={x: mnist.test.images,
43-
y_: mnist.test.labels}))
42+
log.info("test_accuracy: " + str(sess.run(accuracy, feed_dict={x: mnist.test.images, y_: mnist.test.labels})))
4443

45-
log.info("CNNProcessor concluded")
44+
log.info("SoftmaxRegressionProcessor concluded")

tensorflow-mnist/scripts/run-tensorflow-mnist.sh

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,8 @@
22

33
CODEDIR=$(dirname "$0")"/../"
44

5-
# Run Gaussian Mixture Model processor
6-
/usr/bin/python3 "$CODEDIR"/tensorflow_mnist.py
5+
# Run Softmax network processor
6+
/usr/bin/python3 "$CODEDIR"/tensorflow_mnist.py --mode softmax
7+
8+
# Run Convolutional Neural Network learning processor
9+
/usr/bin/python3 "$CODEDIR"/tensorflow_mnist.py --mode cnn

0 commit comments

Comments
 (0)