Tensorflow Problem

PLEASE EXPLAIN HOW THESE TWO ARE DEFINED IN THE BELOW CODE, I COULD’nt FIND THEIR EXPLANATION ANYWHERE OR HOW THEY ARE INITIAILIZED.
mnist.train.num_examples
mnist.train.next_batch

with tf.Session() as sess:
init.run()
for epoch in range(n_epochs):
for iteration in range(mnist.train.num_examples // batch_size):
X_batch, y_batch = mnist.train.next_batch(batch_size)
sess.run(training_op, feed_dict={X: X_batch, y: y_batch})
if epoch % 5 == 0:
acc_train = accuracy.eval(feed_dict={X: X_batch, y: y_batch})
acc_test = accuracy.eval(feed_dict={X: mnist.validation.images, y: mnist.validation.labels})
print(epoch, “Batch accuracy:”, acc_train, “Validation accuracy:”, acc_test)
w = tf.get_default_graph().get_tensor_by_name(“hidden1/kernel:0”).eval()
print(w)
save_path = saver.save(sess, “model_ckps/my_model_final.ckpt”)

Hi,
Here the complete datasets is divided into batches let the dataset size is M. let we are dividing into k equal batches let N. so N(each batch size)=M/k.
This N is the batch size here = mnist.train.num_examples

  1. mnist.train.num_examples should be a number let N as it is batch_size, as that many times the epoch will be run.

  2. mnist.train.next_batch seems to be a function which is taking the batch size as N and split the batch data into train and test and return as two variable and stored in X_batch, y_batch.

  3. These X_batch, y_batch are also seems to be list as it is passed as a value to a dictionary {X: X_batch, y: y_batch} and for every 5 inner epoch if epoch % 5 == 0: it will take one batch, iterate through the data and find the train and test accuracy. like this for all the batches of k and store it into acc_train, acc_test.

  4. Then you are printing the print(epoch, “Batch accuracy:”, acc_train, “Validation accuracy:”, acc_test).

All the best!

So are these predefined?
because they just appeared suddenly in the code and were not initialised earlier,so are they a method in the tensorflow library??

mnist.train.num_examples
mnist.train.next_batch

The batch size and splitting function seems to be user defined. not a keras function.
As per your the above code I told. It should have been defined. If it is not there is a possibility of error.