July 2019
Intermediate to advanced
512 pages
19h 39m
English
Set the number of epochs and number of steps:
num_epochs = 100num_steps = int(len(mnist.train.images)/batch_size)
Now start the TensorFlow Session and perform training:
with tf.Session(graph=graph) as sess: init_op = tf.global_variables_initializer() sess.run(init_op) for epoch in range(num_epochs): for iteration in range(num_steps): batch_data, batch_labels = mnist.train.next_batch(batch_size) feed_dict = {x : batch_data, y : batch_labels} _, loss, acc = sess.run([train_op, total_loss, accuracy], feed_dict=feed_dict) if iteration%10 == 0: print('Epoch: {}, iteration:{}, Loss:{} Accuracy: {}'.format(epoch,iteration,loss,acc))
You can see how the loss decreases over various iterations:
Epoch: 0, iteration:0, ...
Read now
Unlock full access