Skip to Content
PyTorch深度学习
book

PyTorch深度学习

by Posts & Telecom Press, Vishnu Subramanian
May 2024
Intermediate to advanced
212 pages
3h 23m
Chinese
Packt Publishing
Content preview from PyTorch深度学习

第2章 神经网络的构成

理解神经网络的基本组成部分,如张量、张量运算和梯度递减等,对构造复杂的神经网络至关重要。本章将构建首个神经网络的Hello world程序,并涵盖以下主题:

  • 安装PyTorch;
  • 实现第一个神经网络;
  • 划分神经网络的功能模块;
  • 介绍张量、变量、Autograd、梯度和优化器等基本构造模块;
  • 使用PyTorch加载数据。

PyTorch可以作为Python包使用,用户可以使用pip或conda来构建,或者从源代码构建。本书推荐使用Anaconda Python 3发行版。要安装Anaconda,请参考Anaconda官方文档。所有示例将在本书的GitHub存储库中以Jupyter Notebook的形式提供。强烈建议使用Jupyter Notebook,因为它允许进行交互。如果已经安装了Anaconda Python,那么可以继续PyTorch安装的后续步骤。

基于GPU的Cuda 8版安装:

conda install pytorch torchvision cuda80 -c soumith

基于GPU的Cuda 7.5版安装:

conda install pytorch torchvision -c soumith

非GPU版的安装:

conda install pytorch torchvision -c soumith

在本书写作时,PyTorch还不支持Windows,所以可以尝试使用虚拟机或Docker镜像。

下面给出本书介绍的第一个神经网络,它将学习如何将训练示例(即输入数组)映射成目标(即输出数组)。假设我们为最大的在线公司之一Wondermovies工作(该公司按需提供视频服务),训练数据集包含了表示用户在平台上观看电影的平均时间的特征,网络将据此预测每个用户下周使用平台的时间。这是个假想出来的用例,不需要深入考虑。构建解决方案的主要分解活动如下。 ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Python高级编程(第2版)

Python高级编程(第2版)

Posts & Telecom Press, Michał Jaworski, Tarek Ziadé
程序员学数据结构

程序员学数据结构

Posts & Telecom Press, William Smith
金融中的机器学习

金融中的机器学习

Posts & Telecom Press, Jannes Klaas
Python计算机视觉和自然语言处理

Python计算机视觉和自然语言处理

Posts & Telecom Press, Álvaro Morena Alberolaï, Gonzalo Molina Gallegoï, Unai Garay Maestreï

Publisher Resources

ISBN: 9781836200291