Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
li工
apachecn-dl-zh
提交
a7e0c578
A
apachecn-dl-zh
项目概览
li工
/
apachecn-dl-zh
与 Fork 源项目一致
Fork自
OpenDocCN / apachecn-dl-zh
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
A
apachecn-dl-zh
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
a7e0c578
编写于
1月 18, 2021
作者:
W
wizardforcel
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
2021-01-18 22:54:28
上级
4cc9a655
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
20 addition
and
61 deletion
+20
-61
new/pt-dl-handson/1.md
new/pt-dl-handson/1.md
+3
-38
new/pt-dl-handson/3.md
new/pt-dl-handson/3.md
+6
-15
new/pt-tut-17/49.md
new/pt-tut-17/49.md
+1
-2
new/pt-tut-17/63.md
new/pt-tut-17/63.md
+10
-6
未找到文件。
new/pt-dl-handson/1.md
浏览文件 @
a7e0c578
...
...
@@ -133,31 +133,9 @@ with tf.Session() as sess:
如果您忘记了什么是 XOR,则下表应为您提供足够的信息以从内存中重新收集它:
<colgroup><col
style=
"text-align: left"
>
<col
style=
"text-align: left"
>
<col
style=
"text-align: left"
></colgroup>
|
输入
|
输出值
|
| --- | --- |
|
一种
|
乙
|
异或
|
| | 输入 | 输出 |
| --- | --- | --- |
| A | B | 异或 |
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
...
...
@@ -339,20 +317,7 @@ matrix_with_zeros = torch.zeros(3,2)
`rand`
方法为您提供给定大小的随机矩阵,而
`Tensor`
函数返回未初始化的张量。 要从 Python 列表创建张量对象,请调用
`torch.FloatTensor(python_list)`
,它类似于
`np.array(python_list)`
。
`FloatTensor`
是 PyTorch 支持的几种类型之一。 下表列出了可用的类型:
<colgroup><col
style=
"text-align: left"
>
<col
style=
"text-align: left"
>
<col
style=
"text-align: left"
></colgroup>
|
数据类型
|
CPU 张量
|
GPU 张量
|
| 数据类型 | CPU 张量 | GPU 张量 |
| --- | --- | --- |
| 32 位浮点 |
`torch.FloatTensor`
|
`torch.cuda.FloatTensor`
|
| 64 位浮点 |
`torch.DoubleTensor`
|
`torch.cuda.DoubleTensor`
|
...
...
new/pt-dl-handson/3.md
浏览文件 @
a7e0c578
...
...
@@ -109,14 +109,14 @@ pip install torchvision
| MNIST | 70,000
`28 x 28`
手写数字的数据集。 |
| KMNIST | 平假名字符的排列方式与普通 MNIST 相同。 |
| 时尚 MNIST | 类似于 MNIST 的数据集,包含 70,000 张
`28 x 28`
张标记的时尚图片。 |
|
恩尼斯
| 该数据集是一组
`28 x 28`
个手写字符数字。 |
|
可可
| 大规模对象检测,分割和字幕数据集。 |
|
EMNIST
| 该数据集是一组
`28 x 28`
个手写字符数字。 |
|
COCO
| 大规模对象检测,分割和字幕数据集。 |
| LSUN | 类似于 COCO 的大规模“场景理解挑战”数据集。 |
| Imagenet-12 | 2012 年大规模视觉识别挑战赛的 1400 万张图像的数据集。 |
| CIFAR | 以 10/100 类标记的 60,000 张
`32 x 32`
彩色图像的数据集。 |
| STL10 | 另一个受 CIFAR 启发的图像数据集。 |
| SVHN | 街景门牌号码的数据集,类似于 MNIST。 |
|
摄影之旅
| 华盛顿大学提供的旅游景点数据集。 |
|
PhotoTour
| 华盛顿大学提供的旅游景点数据集。 |
以下代码片段给出了 MNIST 数据集的一个示例。 上表中的所有数据集都需要传递一个位置参数,即要下载的数据集所在的路径,或者如果已经下载了该数据集则用于存储该数据集的路径。 数据集的返回值将打印有关数据集状态的基本信息。 稍后,我们将使用相同的数据集来启用转换,并查看数据集输出的描述性。
...
...
@@ -215,19 +215,10 @@ pip install torchtext
`torchtext`
本身是一个包装器实用程序,而不是支持语言操作,因此这就是我在以下示例中使用 spaCy 的原因。 例如,我们使用
**文本检索会议**
(
**TREC**
)数据集,它是一个问题分类器。
<colgroup><col
style=
"text-align: left"
>
<col
style=
"text-align: left"
></colgroup>
|
文本
|
标签
|
| 文本 | 标签 |
| --- | --- |
|
您如何测量地震? | 数据中心
|
|
埃灵顿公爵是谁? | 哼
|
|
`How do you measure earthquakes?`
(您如何测量地震?) |
`DESC`
|
|
`Who is Duke Ellington?`
(埃灵顿公爵是谁?) |
`HUM`
|
用于此类数据集上的 NLP 任务的常规数据预处理管道包括:
...
...
new/pt-tut-17/49.md
浏览文件 @
a7e0c578
...
...
@@ -390,8 +390,7 @@ std::cout << x.grad() << std::endl;
在较高的层次上,在 C++ 中使用 autograd 的最简单方法是先在 Python 中拥有可用的 autograd 代码,然后使用下表将您的 autograd 代码从 Python 转换为 C++:
<colgroup><col
width=
"16%"
>
<col
width=
"84%"
></colgroup>
| 蟒蛇 | C++ |
| Python | C++ |
| --- | --- |
|
`torch.autograd.backward`
|
`torch::autograd::backward`
(
[
链接
](
https://pytorch.org/cppdocs/api/function_namespacetorch_1_1autograd_1afa9b5d4329085df4b6b3d4b4be48914b.html
)
) |
|
`torch.autograd.grad`
|
`torch::autograd::grad`
(
[
链接
](
https://pytorch.org/cppdocs/api/function_namespacetorch_1_1autograd_1a1e03c42b14b40c306f9eb947ef842d9c.html
)
) |
...
...
new/pt-tut-17/63.md
浏览文件 @
a7e0c578
...
...
@@ -109,12 +109,16 @@ def run(rank, size):
当我们希望对流程的通信进行精细控制时,点对点通信非常有用。 它们可用于实现精美的算法,例如
[
百度的 DeepSpeech
](
https://github.com/baidu-research/baidu-allreduce
)
或
[
Facebook 的大规模实验
](
https://research.fb.com/publications/imagenet1kin1h/
)
中使用的算法。(请参阅
[
4.1 节
](
#our-own-ring-allreduce
)
)
## 集体交流
<colgroup><col
width=
"50%"
>
<col
width=
"50%"
></colgroup>
|
[
![Scatter
](
img/3aa3584628cb0526c8b0e9d02b15d876.png
)
](../_img/scatter.png)分散 |
[
![Gather
](
img/7e8670a3b7cdc7848394514ef1da090a.png
)
](../_img/gather.png)收集 |
|
[
![Reduce
](
img/1c451df4406aea85e640d1ae7df6df31.png
)
](../_img/reduce.png)降低 |
[
![All-Reduce
](
img/0ef9693f0008d5a75aa5ac2b542b83ac.png
)
](../_img/all_reduce.png)全减少 |
|
[
![Broadcast
](
img/525847c9d4b48933cb231204a2d13e0e.png
)
](../_img/broadcast.png)广播 |
[
![All-Gather
](
img/4a48977cd9545f897942a4a4ef1175ac.png
)
](../_img/all_gather.png)全聚 |
## 集合通信
| | |
| --- | --- |
| !
[
Scatter
](
img/3aa3584628cb0526c8b0e9d02b15d876.png
)
| 分散 |
| !
[
Gather
](
img/7e8670a3b7cdc7848394514ef1da090a.png
)
| 收集 |
| !
[
Reduce
](
img/1c451df4406aea85e640d1ae7df6df31.png
)
| 归约 |
| !
[
All-Reduce
](
img/0ef9693f0008d5a75aa5ac2b542b83ac.png
)
| 全部归约 |
| !
[
Broadcast
](
img/525847c9d4b48933cb231204a2d13e0e.png
)
| 广播 |
| !
[
All-Gather
](
img/4a48977cd9545f897942a4a4ef1175ac.png
)
| 全部收集 |
与点对点通信相反,集合允许跨
**组**
中所有进程的通信模式。 小组是我们所有过程的子集。 要创建组,我们可以将等级列表传递给
`dist.new_group(group)`
。 默认情况下,集合在所有进程(也称为
**世界**
)上执行。 例如,为了获得所有过程中所有张量的总和,我们可以使用
`dist.all_reduce(tensor, op, group)`
集合。
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录