I am new to tensorflow and the neural net. I am trying to understand that, how the weights are updated after the Gradient Descent function executed? The example code is as below.
with graph.as_default():
weights = tf.Variable(
tf.truncated_normal([image_size * image_size, num_labels]))
biases = tf.Variable(tf.zeros([num_labels]))
logits = tf.matmul(train_dataset, weights) + biases
loss = tf.reduce_mean(
tf.nn.softmax_cross_entropy_with_logits(labels=train_labels, logits=logits))
loss=loss+tf.multiply(beta, nn.l2_loss(weights))
optimizer = tf.train.GradientDescentOptimizer(0.5).minimize(loss)
with tf.Session(graph=graph) as session:
tf.global_variables_initializer().run()
_, l, predictions = session.run([optimizer, loss, train_prediction])
If I understand correctly, when running the “session.run()” the variables weights and the biases will be updated. Will it be updated in the context of whatever values “GradientDescentOptimizer” has count or it will be just another set of the “truncated_normal” values?
If the regularization is applied as below,
loss=loss+tf.multiply(beta, nn.l2_loss(weights))
Then, how the tensorflow will know what is the correct variable to update the weights in the context of regularized weights? I am not getting the working of the TF.
