[PYTHON] A memo when executing the deep learning sample code created from scratch with Google Colaboratory

Introduction This is the content of ** "Deep Learning from scratch-The theory and implementation of deep learning learned with Python" published by O'REILY ** when executing the sample code in the Google Colaboratory environment.

--Get sample data of books from GitHub --About how to mount data (Introduction of connection method because it cannot be used just by uploading data to My Drive) --About image display (Since the image was not displayed in Google Colaboratory even if the sample code was written, an alternative method was introduced)

Chapter 3 Neural Network 3.6.1 ** MNIST dataset ** 3.7.1 ** Neural network inference processing **

It will be a memo when you execute the above contents. (P72〜P75)

Data acquisition ** Get data from GitHub. **(download) https://github.com/oreilly-japan/deep-learning-from-scratch Folder name = ** deep-learning-from-scratch-master **

About uploading and mounting data 1. Upload the folder in My Drive ** Google Drive **. 2. Create a new Google Colaboratory. 3. Mount the drive. (Make the data available in the notebook)

--Click the icon to start the process.
mount_1.png --Connect to Google Drive
connection.png --When drive is displayed, connection is complete
mount_2.png

Move directory You need to change the current directory before entering the first code. cd.png

Import of load_mnist function load_minst関数インポート.png

Run mnist_show.py ――It is possible to omit the code up to the 6th line. (Already executed when importing load_mnist) --Number of the first training image = ** 5 ** --Number of one-dimensional arrays = ** 784, ** --Retransformed from the one-dimensional array to the original shape = ** 28, 28 ** --The training image that should have been displayed is not displayed. = ** It is stored in img but is not displayed. ** ** mnist_show.png

Image display --I tried another display method to check if it is really ** 5 **. --Import matplotlib and display the image. ――We succeeded in displaying the first training image.
5img.png

Run neuralnet_mnist.py --Correct recognition accuracy = ** 0.9352 (93.52%). ** **

Finally I just ran the sample code in Google Colaboratory, but I spent a lot of time. I posted it for the first time so that people who are worried about similar content can use it as much as possible.

Recommended Posts

A memo when executing the deep learning sample code created from scratch with Google Colaboratory
"Deep Learning from scratch" self-study memo (No. 13) Try using Google Colaboratory
"Deep Learning from scratch" Self-study memo (No. 14) Run the program in Chapter 4 on Google Colaboratory
Sample code summary when working with Google Spreadsheets from Google Colab
Deep Learning from scratch 4.3.3 Draw a gradient vector of your own function based on the sample code of partial differential.
"Deep Learning from scratch" Self-study memo (Part 8) I drew the graph in Chapter 6 with matplotlib
[Learning memo] Deep Learning made from scratch [Chapter 7]
[Learning memo] Deep Learning made from scratch [Chapter 5]
[Learning memo] Deep Learning made from scratch [Chapter 6]
Deep learning / Deep learning made from scratch Chapter 7 Memo
"Deep Learning from scratch" Self-study memo (Part 12) Deep learning
[Learning memo] Deep Learning made from scratch [~ Chapter 4]
"Deep Learning from scratch" Self-study memo (9) MultiLayerNet class
Deep Learning from scratch Chapter 2 Perceptron (reading memo)
[Learning memo] Deep Learning from scratch ~ Implementation of Dropout ~
"Deep Learning from scratch" Self-study memo (10) MultiLayerNet class
"Deep Learning from scratch" Self-study memo (No. 11) CNN
Prepare the environment for O'Reilly's book "Deep Learning from scratch" with apt-get (Debian 8)
Deep Learning from scratch The theory and implementation of deep learning learned with Python Chapter 3
Deep Learning from scratch
[Deep Learning from scratch] I implemented the Affine layer
"Deep Learning from scratch" Self-study memo (No. 19) Data Augmentation
"Deep Learning from scratch 2" Self-study memo (No. 21) Chapters 3 and 4
Create a machine learning environment from scratch with Winsows 10
"Deep Learning from scratch" Self-study memo (No. 16) I tried to build SimpleConvNet with Keras
Countermeasures for "Unable to get upper directory" error when using Deep Learning ② created from scratch with spyder of ANACONDA
Try to build a deep learning / neural network with scratch
Code snippets often used when processing videos with Google Colaboratory
Create an environment for "Deep Learning from scratch" with Docker
Deep learning / LSTM scratch code
"Deep Learning from scratch" self-study memo (No. 18) One! Meow! Grad-CAM!
"Deep Learning from scratch" self-study memo (No. 19-2) Data Augmentation continued
"Deep Learning from scratch" self-study memo (No. 15) TensorFlow beginner tutorial
[Deep Learning from scratch] About the layers required to implement backpropagation processing in a neural network
"Deep Learning from scratch" Self-study memo (No. 10-2) Initial value of weight
Deep Learning / Deep Learning from Zero 2 Chapter 4 Memo
Deep Learning / Deep Learning from Zero 2 Chapter 5 Memo
Deep learning from scratch (cost calculation)
Deep Learning / Deep Learning from Zero 2 Chapter 7 Memo
Deep Learning / Deep Learning from Zero 2 Chapter 8 Memo
Deep Learning / Deep Learning from Zero Chapter 5 Memo
Deep Learning / Deep Learning from Zero Chapter 4 Memo
Deep Learning / Deep Learning from Zero 2 Chapter 3 Memo
Deep Learning memos made from scratch
Deep Learning / Deep Learning from Zero 2 Chapter 6 Memo
How to run the practice code of the book "Creating a profitable AI with Python" on Google Colaboratory
[Introduction to machine learning] Until you run the sample code with chainer
Realize environment construction for "Deep Learning from scratch" with docker and Vagrant
Build a "Deep learning from scratch" learning environment on Cloud9 (jupyter miniconda python3)
Deep learning / Deep learning from scratch 2-Try moving GRU
Make a cascade classifier with google colaboratory
"Deep Learning from scratch" in Haskell (unfinished)
[Windows 10] "Deep Learning from scratch" environment construction
Learning record of reading "Deep Learning from scratch"
[Deep Learning from scratch] About hyperparameter optimization
Customize the progress display during learning with tf.keras (Google Colaboratory cell overflow countermeasures)
Feature engineering for machine learning starting with the 4th Google Colaboratory --Interaction features
The story of doing deep learning with TPU
Deep Learning from scratch ① Chapter 6 "Techniques related to learning"
Good book "Deep Learning from scratch" on GitHub
Create a game UI from scratch with pygame2!