PyTorch官方60分钟入门

网址:https://link.zhihu.com/?target=http%3A//pytorch.org/tutorials/

(一) What is PyTorch?

1.Tensors are similar to NumPy’s ndarrays, with the addition being that

Tensors can also be used on a GPU to accelerate computing.

2.Any operation that mutates a tensor in-place is post-fixed with an _.

For example: x.copy_(y), x.t_(), will change x.

3.The Torch Tensor and NumPy array will share their underlying memory

locations (if the Torch Tensor is on CPU), and changing one will change

the other。(在cpu上,改变tensor的同时也会改变numpy,反之亦然)

4.All the Tensors on the CPU except a CharTensor support converting to

NumPy and back.

(二) Autograd: Automatic Differentiation

1.使得tensor不再参与到梯度计算的两种方式:

(1)call .detach() function

(2)将代码块放到with torch.no_grad():里

2.If you want to compute the derivatives, you can call .backward() on

a Tensor. If Tensor is a scalar (i.e. it holds a one element

data), you don’t need to specify any arguments to backward(),

however if it has more elements, you need to specify a gradientargument that is a tensor of matching shape.

3..requires_grad_(...) changes an existing Tensor’s requires_gradflag in-place. The input flag defaults to False if not given(如果没有明确设置,则requires_grad默认为false)

4. Each tensor has

a .grad_fn attribute that references a Function that has created

the Tensor (except for Tensors created by the user - their grad_fn is None)(每个tensor都记录着创建它的操作,例如该tensor通过加操作被创作,则会有grad_fn=<AddBackward0>,若其初始是被人所创建,则grad_fn为None)

(三) Neural Networks

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • rljs by sennchi Timeline of History Part One The Cognitiv...
    sennchi阅读 12,181评论 0 10
  • tensorflow开发API 架构 Modules app module: Generic entry poin...
    sennchi阅读 5,202评论 0 2
  • 本篇阅读时间约为7分钟本节为过度章节,讲述了颁奖时左峟的心理活动。 “方纾,我刚听到一首特别好听的歌!特别好听!”...
    席乐幽阅读 5,395评论 33 14
  • 每个人都会失去一些东西,就像该来的总会来,该走的不必挽留一样,未来会以另一种形式弥补你,不是过错,也从未错...
    北梦沐曦阅读 3,134评论 2 4
  • 2019年立下的flag不少,但是启动的都有坚持。 前天参加了一位老师的写作日更活动,每天一百字更文。许久未有认真...
    孖弋阅读 1,166评论 0 1

友情链接更多精彩内容