-
-
Save mmeendez8/3643d657ae490dfc762c66d11331ab0e to your computer and use it in GitHub Desktop.
Test iterator and show images
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import matplotlib.pyplot as plt | |
| init_vars = [tf.local_variables_initializer(), tf.global_variables_initializer()] | |
| with tf.Session() as sess: | |
| sess.run([init_vars, iterator.initializer]) # Initialize variables and the iterator | |
| while 1: # Iterate until we get out of range error! | |
| try: | |
| batch = sess.run(input_batch) | |
| print(batch.shape) # Get batch dimensions | |
| plt.imshow(batch[0,:,:,0] , cmap='gray') | |
| plt.show() | |
| except tf.errors.OutOfRangeError: # This exception is triggered when all batches are iterated | |
| print('All batches have been iterated!') | |
| break |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment