“This article has participated in the good article call order activity, click to see: back end, big front end double track submission, 20,000 yuan prize pool for you to challenge!”

Deep learning programming tools commonly used

Let’s start with four common programming tools: Sublime Text, Vim, Jupyter. Although I introduced Jupyter, you are not required to use it, you can choose according to your own preferences.

Sublime Text

The first is Sublime Text, which is a very lightweight and powerful Text editing tool with a lot of quick features built in and rich plug-in support, which is very convenient for us.

As shown in the figure above, it automatically generates indexes for the classes, methods, and functions in the project, allowing us to track our code. Using its goto Anything function, you can find the corresponding line of code in a project based on some keywords.

Vim

The second is Vim, which is a quick, convenient and powerful text editing tool on Linux that we use frequently in our projects.

In our projects, we often need to log in to a server for development, and the server is usually a Linux system with no Sublime Text or Pycharm, so we can open the code directly with Vim for editing. For those who have not been exposed to Linux or have been using IDE for programming and development, it may not be very convenient at the beginning, but Vim has rich shortcut keys, which is very convenient for Shell and Python development.

The downside of Vim, as I said, is that there’s a little bit of a threshold and you need to learn how to use it. Once you learn it, I promise you will love it.

Jupyter Notebook & Lab

Finally, today’s Jupyter Notebook is an open source Web application that lets you create and share documents containing executable code, visual structures, and text descriptions.

Jupyter Notebook has a wide range of applications. It can be used in data cleaning and transformation, digital simulation, statistical model, data visualization, machine learning and other aspects.

Jupyter Notebooks is very active in the deep learning arena. During the experimental testing phase of a project, it is more convenient than programming directly from a PY file. If you want to write a project report after the project, use Jupyter is also more appropriate.

After a brief introduction, we will study the three aspects of Jupyter from the functions of Jupyter, the installation and startup of Jupyter and the operation of Jupyter Lab.

Jupyter Notebook & Lab features

Jupyter has three main functions: code execution, data visualization, and report writing using Markdown.

  • Execute the code. Usually Python programs, but new programming languages can also be added.
  • Data visualization. Imagine that we are often programming in a Linux environment. What if we need to visualize the data? Can I only save the image and download it to view locally? Using Jupyter Notebook, we don’t have to do anything, we can just look at it in the page. As shown in the figure below:

  • Use the Markdown function to write a document, or create a POWERPOINT presentation. These documents also contain the code and the results of the code’s execution, and are very helpful when writing project reports.

Install and start up Jupyter Notebook & Lab

After understanding the functions of Jupyter, let’s take a look at how to install and start. In this section, I’ve covered three ways to install and start: Anaconda, Docker, and PIP.

Install and start using Anaconda

Let’s first look at how to install and start using Anaconda.

The installation

The easiest way to use Jupyter Notebook & Lab is by installing Anaconda. Anaconda has automatically installed the Jupter Notebook and other tools, along with more than 180 science packages and their dependencies in Python. The Anaconda download tool is available at Anaconda’s official website.

Start the

I’m going to break it down into MacOS and Windows.

(1) MacOS

After Anaconda is installed, the system enters the Base environment by default after you open the terminal.

A **(base)** flag at the top of the command line indicates that the code has entered the base environment. If not, activate the base environment with the following command:

conda activate base
Copy the code

Execute the following command in base environment, will automatically enter the development environment of Jupyte Notebook.

jupyter notebook
Copy the code

Execute the following command, will automatically enter the Jupyter Lab development environment.

jupyter lab
Copy the code

(2) Win environment

The boot mode in Windows is basically the same as on MacOS.

When you want to launch the Jupyter Notebook or Jupyter Lab command, you need to do it in the Anaconda Prompt.

Launch from Anaconda Navigator in the same way as MacOS.

Using a Docker

Using Jupyter through Docker is also very simple, even installation is not required, but the premise is that you have Docker related knowledge.

Install and start using PIP

After looking at how Anaconda and Docker are installed and started, let’s finally look at how PIP is installed and started.

The installation

Install the Jupyter Notebook via PIP:

pip install Jupyter
Copy the code

Install Jupyter Lab via PIP:

pip install Jupyterlab
Copy the code

Start the

After the installation is complete, run the Jupyter Notebok or Jupyter Lab command on the terminal to start the device.

Whether on MacOS or Windows, the browser automatically opens the Jupyter Notebook or Jupyter Lab development environment after successfully launching either of the above methods:

Operation of Jupyter Lab

Jupyter Lab is the next generation product of Jupyter Notebook, which is more flexible and convenient in use.

After we launch Jupyter Lab from the command line or Anaconda Navigator, the browser will automatically open the Jupyter Lab interface as shown below:

On the far left is the directory where you started, and on the right are the development tools you can use.

Notebook

Clicking the “Python 3” icon under the Notebook will automatically create a new Notebook.

  • This editing tool called Notebook is used in both Jypter Lab and Jupyter Notebook.

  • The difference between Jupyter Lab and Jupyter Notebook is the INTERFACE and operation mode of IDE. The operation of Jupyter Lab is explained here.

A Notebook’s editing interface consists of four main parts: the menu bar, the toolbar, the Cell, and the kernel. As shown in the figure below:

Menu bar and toolbar here will not be detailed. Let’s look at cells first, and then the kernel.

Cell

Cells are going to be the main thing in Notebook, and I’m going to talk about two types of cells.

  • Code cell: Contains the Code that can be run in the kernel and prints the results below the cell.

  • Markdown cell: Contains a document using Markdown, often used for documentation, and is a running cell.

The shortcut key for switching from Code cell to Markdown cell is M; The shortcut key for switching from Markdown cells to Code cells is Y.

Before switching, you need to press Esc to exit from the edit state of the cell.

You can also switch in the toolbar, but the shortcut keys are more convenient. The position of the toolbar is the position of the red box in the following picture:

Let’s look at an example. I edited the following Notebook. The first line is a Markdown cell, which is a level 1 header, and the second line is a piece of Python code. Both lines of code are not running.

Do you notice the blue bar on the left? It represents the cell we’re in.

When we edit this cell, the left side is the green bar. If we press Esc to exit the cell, it will turn blue.

After exiting the cell, we can move the selected cell by pressing up or down. We move to the first row, and we start running these two cells.

Ctrl+Enter is the shortcut for running a single cell, and Shift +Enter is the shortcut for selecting a cell and switching to the next cell. The running result is as shown in the figure below:

Markdown does not have a “[]” tag on the left, which allows you to distinguish Code cells from Markdown cells.

The number in “[]” represents the order in which cells are executed. In this example, “[1]” represents the first cell to be executed.

So that’s the contents of the cell. Let’s look at the use of some shortcuts in the cell.

(1) Shortcut keys

If you are using Jupyter to develop, mastering cell shortcuts can make your development faster. Here are a few common shortcuts:

  • Execute the cell Ctrl+Enter or Shift+Enter;
  • A Insert a new cell above the cell;
  • B Insert a new cell below the cell;
  • X Delete cells;
  • Z Undo the deleted cell.

(2) Magic command

The Jupyter Notebook’s predecessor is the IPython Notebook, so Jupyter also supports IPython’s Magic command. IPython is a Shell that is more flexible and convenient than the Shell that comes with Python, and it is mainly active in data science.

There are two types of Magic commands:

  • Line Magics command: If you add % before the command, the command is valid only on the Line

  • Cell Magics command: Add %% before the command to indicate that the command is valid in the entire Cell.

Let me introduce a few common Magic commands.

  • %lsmagic: Displays available Magic commands.

  • %matplotlib inline: Prints the matplotlib icon directly below the cell. This is usually used before the matplotlib module is introduced. With this Magic command, you don’t need plt.show().

  • % PWD: Displays the current file path.

  • %%writefile: writes a file. %%writefile follows the file name and then writes the contents of the file.

  • %run: Run a file, %run followed by the file to run.

  • %load: loads the file. Use %load + file name to load the specified file into the cell. In the following example, we want to load temp.py into a cell, first before execution,

(3) Markdown command

Now that we’ve looked at the Magic command, let’s look at the Markdown command. Markdown is a language used to format text in a Markdown unit. It is commonly used for Notebook documentation. We have listed several common commands.

  • Title: The size of the title can be determined by the number of hash signs.
# Level 1 title:

## Secondary title:

### #

#### Level 4 Title:

##### Level 5 Title:
Copy the code
  • List: divided into unordered list and ordered list.
## Unordered list

-Project 1-Project 2## Ordered list

1.Item 1 (1. A space between item 1 and item 1)2.Project 2Copy the code
  • Font: The number of “*” or “_” can be used to control the emphasis, i.e., italics, boldface, and bold italics. See the following example for details.
* italics *

Bold * * * * 

支那* bold italic支那* or _ italic _Bold (

___ bold italic___ Copy the code

(4) Invoke system commands

Finally, you can call the operating system’s commands from the Notebook by putting a “! “in front of the command. That will do. For example, to view the current path on a Linux OS:

!pwd
Copy the code