Search notes:

Python matplotlib example: MNIST character

The following matplotlib example tries to demonstrate how a character of the MNIST database can be drawn:
import tensorflow as tf
import matplotlib.pyplot as plt

(x_train, y_train), (x_test, y_test) = tf.keras.datasets.mnist.load_data()

image = x_train[1234]

fig = plt.figure(figsize=(1, 1))

#
# change 'gray_r' to 'gray' for white-on-black image
#
plt.imshow(image, cmap='gray_r')

plt.axis('off')
plt.savefig('img/MNIST-character.png', bbox_inches='tight', pad_inches=0, dpi=250)
# plt.show()
Github repository about-python, path: /libraries/matplotlib/_examples/MNIST-character.py
When executed, the following image is produced:

See also

Displaying multiple MNIST digits in a grid

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/developm...', 1759226066, '216.73.216.128', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/development/languages/Python/libraries/matplotlib/_examples/MNIST-character(57): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78