pip quickly installs torch, opencv, and scipy libraries

 

Table of contents

1. pip install torch

1.1 Introduction to torch

1.2 Import of torch.nn related libraries

1.3 Torch installation command on win10

2. Install Opencv with pip 

 3. Install scipy library with pip


1. pip install torch

1.1 Introduction to torch

    Basic functions of torch:
    ①torch: Tensor related operations, such as: creation, indexing, slicing, continuity, transposition, addition Related operations such as subtraction, multiplication and division.

    ②torch.nn: Contains modules for building the network layer and a series of loss functions.

For example: fully connected, convolution, pooling, BN batch processing, dropout, CrossEntropyLoss, MSLoss, etc.

Contains five basic functional modules: nn.Parameter, nn.Linear, nn.functional, nn.Module, nn.Sequential

    ③torch.autograd: Provides automatic derivation methods for all operations of Tensor.

    ④torch.nn.functional:Commonly used activation functions relu, leaky_relu, sigmoid, etc.

    ⑤torch.optim: Various parameter optimization methods, such as: SGD, AdaGrad, RMSProp, Adam, etc.

    ⑥torch.nn.init: You can use it to change the default parameter initialization method of nn.Module.

    ⑦torch.utils.data:Used by the user.

1.2 Import of torch.nn related libraries

    The torch.nn library is a modular interface specially designed for neural networks. nn is built on autograd. nn is the abbreviation of Neural Network. It can be used to define and run neural networks and help programmers perform the following behaviors related to neural networks. .

(1) Create a neural network

(2) Training neural network

(3) Save neural network

(4) Restore neural network

    The import of torch.nn related libraries is as follows:

import numpy as np              # numpy数组库
import math                     # 数学运算库
import matplotlib.pyplot as plt # 画图库
 
import torch             # torch基础库
import torch.nn as nn    # torch神经网络库
import torch.nn.functional as F

1.3 Torch installation command on win10

pip install torch===1.7.1 torchvision===0.4.1 -i https://pypi.tuna.tsinghua.edu.cn/simple

The following interface will appear: 

Note: [Pytorch Series-30]: Neural Network Basics - Five basic functions of the torch.nn library: nn.Parameter, nn.Linear, nn.functioinal, nn.Module, nn.Sequentia

[Pytorch Series-30]: Neural Network Basics - Five basic functions of the torch.nn library: nn.Parameter, nn.Linear, nn.functioinal, nn.Module, nn.Sequentia_nn.parameter and nn.linear_silicon base of simmering sugar Workshop Blog-CSDN Blog

2. Install Opencv with pip 

(1) win+R and enter cmd;

(2) Then switch to the location where anaconda is installed, and then enter the location of the Script folder.​ 

(3) Enter the following commands in sequence:

pip install opencv-python -i https://pypi.tuna.tsinghua.edu.cn/simple
pip install opencv-contrib-python -i https://pypi.tuna.tsinghua.edu.cn/simple

(4) Enter conda list to check whether the download is successful. The following logo will appear.

 3. Install scipy library with pip

(1) Install Numpy: Because Scipy depends on Numpy, you need to install Numpy first. The command is as follows:

pip install numpy

(2) Install Scipy

pip install scipy

Guess you like

Origin blog.csdn.net/m0_53096519/article/details/133864451