I am doing character recognition by building a Convolutional Neural Network model in Tensorflow. My model has 2 Conv layer followed by 2 fully connected layer. I have around 78K images from training and 13K images for testing. When I execute the model, I got accuracy around 92.xx% on test set. When I visualized my accuracy and loss curve on Tensorboard. I got a vertical line, but I did not know why I am getting this? I got curve like this Accuracy and Cross Entropy curve when viewed on tensorboard.
Also distribution curve of weights and biases shows a vertical line Left side shows testing parameters (weights and bias) and right side shows training parameters on first conv layer
Any help in this regard is highly appreciated. !!
def conv_layer(input, size_in, size_out, name="conv"):
with tf.name_scope(name):
w = tf.Variable(tf.random_normal([5, 5, size_in, size_out], stddev=0.1), name="W")
b = tf.Variable(tf.constant(0.1, shape=[size_out]), name="B")
conv = tf.nn.conv2d(input, w, strides=[1, 1, 1, 1],padding="VALID")
act = tf.nn.relu(conv + b)
tf.summary.histogram("weights", w)
tf.summary.histogram("biases", b)
tf.summary.histogram("activations", act)
return tf.nn.max_pool(act, ksize=[1, 2, 2, 1], strides=[1, 2, 2, 1], padding="SAME")`
def fc_layer(input, size_in, size_out, name="fc"):
with tf.name_scope(name):
w = tf.Variable(tf.random_normal([size_in, size_out], stddev=0.1), name="W") # Truncated_normal
b = tf.Variable(tf.constant(0.1, shape=[size_out]), name="B")
act = tf.matmul(input, w) + b
tf.summary.histogram("weights", w)
tf.summary.histogram("biases", b)
tf.summary.histogram("activations", act)
return act
def model(use_two_conv, use_two_fc):
sess = tf.Session()
x = tf.placeholder(tf.float32, shape=[None, 1024], name="x")
x_image = tf.reshape(x, [-1, 32, 32, 1])
tf.summary.image('input', x_image, 3)
y = tf.placeholder(tf.float32, shape=[None,46], name="labels")
if use_two_conv:
conv1 = conv_layer(x_image, 1, 4, "conv1")
conv_out = conv_layer(conv1,4,16,"conv2")
else:
conv1 = conv_layer(x_image, 1, 16, "conv1")
conv_out = tf.nn.max_pool(conv1, ksize=[1, 2, 2, 1], strides=[1, 2, 2, 1], padding="SAME")
flattened = tf.reshape(conv_out, [-1, 5 * 5 * 16])
if use_two_fc:
fc1 = fc_layer(flattened, 5 * 5 * 16, 200, "fc1")
relu = tf.nn.relu(fc1)
tf.summary.histogram("fc1/relu", relu)
logits = fc_layer(fc1, 200, 46, "fc2")
else:
logits = fc_layer(flattened, 5*5*16, 46, "fc")
writer.add_summary(current_summary)
instead ofwriter.add_summary(current_summary, epoch)
. If you post the code, I'll happily post this as an answer. – Dylan F