An amateur stumbled in Deep Learning from scratch Note: Chapter 1

Introduction

Suddenly, "Deep Learning from scratch-the theory and implementation of deep learning learned from Python" and "Deep Learning from scratch (" 2) --- Natural Language Processing " I decided to study.

However, I am very worried whether it will continue because I do not have enough time. However, when I finished "Language processing 100 knocks 2015" two or three years ago, [Amateur language processing I continued to post to Qiita as 100 knocks, and thanks to everyone's likes and comments, I was able to finish it, so this time as well I decided to help.

This time, I will make a note of what I stumbled upon in this book, chapter by chapter. If you have any mistakes, I would be grateful if you could point them out in the same way as when 100 knocks on amateur language processing.

(To other chapters of this memo: Chapter 1 / Chapter 2 / Chapter 3 / Chapter 4 / Chapter 5 / [Chapter 6](https: / /qiita.com/segavvy/items/ca4ac4c9ee1a126bff41) / Chapter 7 / Chapter 8 / Summary)

My environment

This time we will proceed with macOS Mojave.

The actual operating environment is a virtual machine in the form of Mac on Mac. If the hardware is a Mac, I would normally use it as it is, but considering trial and error when building a development environment, virtual machines are more convenient because they can be branched and returned with snapshots.

Below are the details of the environment.

item environment
hard Mac mini(Late 2012)
Host OS macOS Mojave version 10.14.6
Virtualization infrastructure Parallels Desktop 15 for Mac Pro Edition Version 15.0.0 (46967)
Guest OS macOS Mojave version 10.14.6

Building this virtual machine is summarized in Build a macOS Virtual Machine in Parallels Desktop (https://qiita.com/segavvy/items/306bd6574a42c35d860c).

Chapter 1 Introduction to Python

Chapter 1 is an introduction to Python. I was doing 100 knocks on language processing in Python, so this chapter feels like a review of Python. ..

1.1 What is Python?

The explanation is that Python is good.

1.2 Python installation

I installed Anaconda according to the book. I didn't have any particular stumbling blocks, but the book only mentions about 3 lines about installation, so I'll briefly summarize the procedure.

First, "Download" from the Anaconda site (https://www.anaconda.com/distribution) listed in the book. Unfortunately it is in English. スクリーンショット 2019-10-27 12.44.16.png

You will be asked for the Python version, so "Download" the 3rd series 3.7 according to the book. スクリーンショット 2019-10-27 12.45.15.png

Run the downloaded installer to install it. This was in Japanese. スクリーンショット 2019-10-27 12.47.26.png I was asked where to install it on the way, so I chose "Install for myself". If you're not sharing your Mac with others, this is fine. スクリーンショット 2019-10-27 12.47.57.png スクリーンショット 2019-10-27 12.48.07.png After that, you can install it if you proceed normally.

1.3 Python interpreter

Check the version in the terminal and run the interpreter. スクリーンショット 2019-11-02 12.17.35.png It seems that it has been installed correctly. By the way, the Python version was 3.7.4.

1.4 Python script file

If you use macOS Standard TextEdit as your text editor, set the format to standard text. Otherwise, you will not be able to save with the extension .py. スクリーンショット 2019-11-02 21.40.05.png You can leave the "Standard Text Encoding" as "Unicode (UTF-8)" when saving. スクリーンショット 2019-11-02 21.50.42.png Run cd to the location you saved in the terminal. スクリーンショット 2019-11-02 22.00.17.png Good vibes! There seems to be no problem in handling Japanese.

(Derailment) Preparing Visual Studio Code

TextEdit isn't really good for coding, so I decided to use Visual Studio Code. You can find a lot of installation and usage by google, so here I will summarize only the installation flow.

  1. First, install Visual Studio Code. As I mentioned earlier, in the form of Mac on Mac, when I installed it normally, I got stuck around the display, so Use Visual Studio Code for the time being with the macOS virtual machine of Parallels Desktop / segavvy / items / 802aa24d6893ef3b174c) has been summarized.

  2. Add the "Python extension for Visual Studio Code" distributed by Microsoft for convenient use in Python. @ tkdrecord's I tried to develop Python with Visual Studio Code on Mac is helpful. スクリーンショット 2019-11-23 20.25.23.png

  3. Add the "Japanese Language Pack for Visual Studio Code" distributed by Microsoft to use Japanese notation. You can refer to @ ntkgcj's Visual Studio Code [vsCode] Japanese localization. スクリーンショット 2019-11-23 20.31.57.png

  4. Add flake8 as a Linter for static analysis of your code. You can refer to @ firedfly's Comfortably follow VS Code coding standards. スクリーンショット 2019-11-24 23.32.36.png

  5. Add autopep8 as a Formatter that will format your code. This is also helpful to @ firedfly's Comfortably follow VS Code coding conventions. スクリーンショット 2019-11-24 23.35.12.png

  6. Add autoDocstring so that you can easily write docstrings such as function descriptions. This is also helpful to @ firedfly's Comfortably follow VS Code coding conventions. スクリーンショット 2019-11-24 23.37.05.png

  7. A message will appear in the lower right corner at startup. スクリーンショット 2019-12-03 9.23.42.png When using the integrated terminal in the environment of conda (included in Anaconda), it is better to set it so that it does not inherit the environment settings of Visual Studio Code. Do you want to change the settings? It seems that it means that, so let's say "Yes".

Now you can write your code in Visual Studio Code and easily run it with the green triangle button in the upper right corner. スクリーンショット 2019-12-03 9.35.10.png Good vibes!

1.5 NumPy NumPy is included in Anaconda, so you can use it as is. スクリーンショット 2019-11-02 22.09.38.png

1.6 Matplotlib Matplotlib is also included in Anaconda, so you can use it as is. スクリーンショット 2019-11-02 22.27.56.png The image lena.png used in the book is published on O'Reilly Japan's GitHub repository together with other sources that appear in this book, so take this opportunity to download it all at once ( Let's clone).

First, the GitHub repository for this book (https://github.com/oreilly-japan/deep-learning-from-scratch) ). スクリーンショット 2019-11-02 22.41.48.png Here, select "Clone or download" and "Download ZIP". スクリーンショット 2019-11-02 22.42.10.png There is lena.png in the dataset folder in the download, so you can display it by writing the code to point to the path of this file according to the book. スクリーンショット 2019-11-02 22.50.41.png By the way, who is this woman? For those who say, [Lenna (image data)] on Wikipedia (https://ja.wikipedia.org/wiki/%E3%83%AC%E3%83%8A_(%E7%94%BB%E5%83%8F) Please explain% E3% 83% 87% E3% 83% BC% E3% 82% BF)).

1.7 Summary

As you can see in the book, this chapter is the bare minimum of Python, NumPy, and Matplotlib. I had already touched it with Knock 100 language processing, so it was just right for review, but if you are not satisfied with the book I think it would be good to study with the reference books introduced.

That's all for this chapter. If you have any mistakes, I would be grateful if you could point them out. (To other chapters of this memo: Chapter 1 / Chapter 2 / Chapter 3 / Chapter 4 / Chapter 5 / [Chapter 6](https: / /qiita.com/segavvy/items/ca4ac4c9ee1a126bff41) / Chapter 7 / Chapter 8 / Summary)

Recommended Posts

An amateur stumbled in Deep Learning from scratch Note: Chapter 1
An amateur stumbled in Deep Learning from scratch Note: Chapter 3
An amateur stumbled in Deep Learning from scratch Note: Chapter 7
An amateur stumbled in Deep Learning from scratch Note: Chapter 5
An amateur stumbled in Deep Learning from scratch Note: Chapter 4
An amateur stumbled in Deep Learning from scratch Note: Chapter 2
Making from scratch Deep Learning ❷ An amateur stumbled Note: Chapter 5
Making from scratch Deep Learning ❷ An amateur stumbled Note: Chapter 2
Making from scratch Deep Learning ❷ An amateur stumbled Note: Chapter 7
Making from scratch Deep Learning ❷ An amateur stumbled Note: Chapter 1
Making from scratch Deep Learning ❷ An amateur stumbled Note: Chapter 4
Making from scratch Deep Learning ❷ An amateur stumbled Note: Chapter 6
[Learning memo] Deep Learning made from scratch [Chapter 7]
Deep learning / Deep learning made from scratch Chapter 6 Memo
[Learning memo] Deep Learning made from scratch [Chapter 5]
[Learning memo] Deep Learning made from scratch [Chapter 6]
"Deep Learning from scratch" in Haskell (unfinished)
Deep learning / Deep learning made from scratch Chapter 7 Memo
[Learning memo] Deep Learning made from scratch [~ Chapter 4]
Deep Learning from scratch
Deep Learning from scratch ① Chapter 6 "Techniques related to learning"
Deep Learning from scratch Chapter 2 Perceptron (reading memo)
Deep Learning from scratch 1-3 chapters
Deep Learning / Deep Learning from Zero 2 Chapter 4 Memo
Deep Learning / Deep Learning from Zero Chapter 3 Memo
Deep Learning / Deep Learning from Zero 2 Chapter 5 Memo
Create an environment for "Deep Learning from scratch" with Docker
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
[Deep Learning from scratch] I tried to explain the gradient confirmation in an easy-to-understand manner.
"Deep Learning from scratch" Self-study memo (No. 14) Run the program in Chapter 4 on Google Colaboratory
"Deep Learning from scratch" Self-study memo (Part 8) I drew the graph in Chapter 6 with matplotlib
Why ModuleNotFoundError: No module named'dataset.mnist' appears in "Deep Learning from scratch".
Write an impression of Deep Learning 3 framework edition made from scratch
Deep learning from scratch (forward propagation edition)
Deep learning / Deep learning from scratch 2-Try moving GRU
[Windows 10] "Deep Learning from scratch" environment construction
Learning record of reading "Deep Learning from scratch"
[Deep Learning from scratch] About hyperparameter optimization
"Deep Learning from scratch" Self-study memo (Part 12) Deep learning
Python vs Ruby "Deep Learning from scratch" Chapter 2 Logic circuit by Perceptron
Python vs Ruby "Deep Learning from scratch" Chapter 4 Implementation of loss function
"Deep Learning from scratch" self-study memo (unreadable glossary)
"Deep Learning from scratch" Self-study memo (9) MultiLayerNet class
An amateur tried Deep Learning using Caffe (Introduction)
Good book "Deep Learning from scratch" on GitHub
An amateur tried Deep Learning using Caffe (Practice)
[Learning memo] Deep Learning from scratch ~ Implementation of Dropout ~
An amateur tried Deep Learning using Caffe (Overview)
Python vs Ruby "Deep Learning from scratch" Summary
"Deep Learning from scratch" Self-study memo (10) MultiLayerNet class
"Deep Learning from scratch" Self-study memo (No. 11) CNN
Python vs Ruby "Deep Learning from scratch" Chapter 3 Implementation of 3-layer neural network
[Python] [Natural language processing] I tried Deep Learning ❷ made from scratch in Japanese ①
Deep Learning from scratch The theory and implementation of deep learning learned with Python Chapter 3