PyTorch深度学习快速入门

  • 名称:PyTorch深度学习快速
  • 分类:人工智能  
  • 观看人数:加载中
  • 时间:2022/7/23 11:29:29

1.Pytorch简介:        

Pytorch是Python里的用来进行深度学习的框架,能够在强大的GPU加速基础上实现张量和动态神经网络,如果没有GPU,也支持CPU版本的。它的一大优势就是动态计算特征,也就是计算图在运行的时候创建。目前市场上支持动态计算的框架有Pytorch、DyNet、Chainer,而支持静态图计算的框架有TensorFlow,MXNet,Theano。        

Pytorch本质上是支持GPU的Numpy替代,提供了用来创建和训练神经网络 的高级API。要想快速上手它,需要熟悉Numpy、Python和深度学习的一些基本概念。

2.学习途径:        

目前网上关于Pytorch的教程真的是名目繁多,怎么选择一个通俗易懂、系统化的的教程就显得尤为重要。小编结合自身对Pytroch的学习,以及对学习资源的筛选,下面为读者提供一些专业的学习网站,希望可以方便大家更好的学习。       

1.Pytorch官网:Pytorch官网可以直接百度:pytorch,第一个就是官方文档。官网是对Pytorch最权威、最全面、最官方的解读。常用的接口与功能在这里都可以找到对应的说明。平时多看看官方文档,可以学到别的地方学不到的一些东西。        

2.github:  这是一个开源的入门级的pytorch教程,简单,实用(由于公众号文章不能引用外部链接,想要学习这个的话,直接复制路径所有即可)        

3.莫烦Python:  直接百度莫烦Python,就可以找见。莫烦教程里面涵盖了深度学习常用的框架视频和代码。小编自认为这个教程最合适新手的入门,详细的文档、全面的视频讲解、还配备了对应的视频代码,值得去系统的学习。

3.Pytorch的安装:

Pytorch0.4.0之前只支持MacOS和Linux两种系统,并且支持多种安装方式,Pytorch0.4.0之后开始支持Windows系统。官网上介绍基于conda、pip和源码编译几种不同的安装方式。支持的版本有python2.7、python3.5和python3.6。鉴于深度学习需要的计算一般比较大,强烈建议找一个独立显卡的电脑展开学习,当然要是没有显卡,就是计算速度会大大降低。小编安装了一个Ubuntun16.04的双系统,而且本机没有显卡,所以环境的搭建与后边代码都是基于CPU下Ubuntu完成的。由于已经习惯了使用  mkvirtulenv来管理自己的环境(conda可以下载非python的安装包,当前这个环境所使用的包都是python包,所以在这个环境里两者无差别)。环境搭建提供mkvirtulenv和conda两种安装方式。

下面这个图来源属于Pytorch官网,操作系统、安装包管理工具、Python版本和CUDA分别可以根据自己的电脑配置来选择

1. Introduction to pytoch:

Pytorch is a framework used for deep learning in Python. It can realize tensor and dynamic neural network on the basis of powerful GPU acceleration. If there is no GPU, it also supports CPU version. One of its advantages is the dynamic computing feature, that is, the computing graph is created at run time. At present, pytoch, dynet and chainer are the frameworks that support dynamic computing in the market, while tensorflow, mxnet and theano are the frameworks that support static graph computing.        

Pytoch is essentially a numpy alternative to GPU, providing a high-level API for creating and training neural networks. To get started quickly, you need to be familiar with some basic concepts of numpy, Python and deep learning.

2. Learning approach:

At present, there are many online tutorials about pytoch. How to choose an easy to understand and systematic tutorial is particularly important. In combination with my own learning of pytroch and the screening of learning resources, the editor will provide readers with some professional learning websites, hoping to facilitate everyone's better learning.        

1. Pytorch official website: pytorch official website can be directly Baidu: pytorch. The first is the official documents. The official website is the most authoritative, comprehensive and official interpretation of pytoch. The corresponding descriptions of common interfaces and functions can be found here. You can learn something you can't learn elsewhere by reading more official documents.         

2.github: this is an open source entry-level pytorch tutorial, which is simple and practical (since the official account article cannot quote external links, if you want to learn this, you can directly copy all the paths)

3. Don't bother Python: don't bother Python directly in Baidu, and you can find it. Don't bother the tutorial, which covers the framework videos and code commonly used for in-depth learning. Xiaobian thinks that this tutorial is the most suitable for beginners. The detailed documents, comprehensive video explanations, and the corresponding video code are also equipped, which is worth studying systematically.

3. Pytoch installation:

Before pytorch0.4.0, only MacOS and Linux systems were supported, and multiple installation methods were supported. After pytorch0.4.0, Windows systems were supported. Several different installation methods based on CONDA, PIP and source code compilation are introduced on the official website. Supported versions are python2.7, python3.5, and python3.6. In view of the large amount of computing required for deep learning, it is strongly recommended to find a computer with an independent graphics card to learn. Of course, if there is no graphics card, the computing speed will be greatly reduced. Xiaobian has installed a dual system of ubuntun16.04, and the machine has no graphics card, so the construction of the environment and the subsequent code are based on Ubuntu under CPU. Because you are used to using mkvirtulenv to manage your environment (CONDA can download non Python installation packages. Currently, the packages used in this environment are Python packages, so there is no difference between the two in this environment). Environment setup provides mkvirtulenv and CONDA installation methods.

The source of the following figure belongs to the pytoch official website. The operating system, installation package management tool, python version and CUDA can be selected according to their own computer configuration