Reputation: 53
#layer 1
w1 = tf.Variable(tf.zeros([784, 30]))
b1 = tf.Variable(tf.zeros([30]))
y1 = tf.nn.relu(tf.matmul(X, w1) + b1)
#layer 2
w2 = tf.Variable(tf.zeros([30, 10]))
b2 = tf.Variable(tf.zeros([10]))
logits = tf.matmul(y1, w2) + b2
preds = tf.nn.softmax(logits)
Hi I'm new to tensorflow and neural network. I tried to implement a two-layer neural network for digit recognition. The code works fine when there is only one layer but after I add the second layer the accuracy dropped to 0.11xxxx. What's wrong with my code? Thanks in advance
Upvotes: 1
Views: 196
Reputation: 4918
You may initialize the weights using random_normal.
w1 = tf.Variable(tf.random_normal([784, 30]))
...
w2 = tf.Variable(tf.random_normal([30, 10]))
Upvotes: 2