pyd2l 1.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pyd2l-1.0.0/LICENSE +201 -0
- pyd2l-1.0.0/MANIFEST.in +3 -0
- pyd2l-1.0.0/PKG-INFO +99 -0
- pyd2l-1.0.0/README.md +83 -0
- pyd2l-1.0.0/pyd2l/LICENSE +16 -0
- pyd2l-1.0.0/pyd2l/README.md +65 -0
- pyd2l-1.0.0/pyd2l/__init__.py +12 -0
- pyd2l-1.0.0/pyd2l/torch.py +2758 -0
- pyd2l-1.0.0/pyd2l.egg-info/PKG-INFO +99 -0
- pyd2l-1.0.0/pyd2l.egg-info/SOURCES.txt +15 -0
- pyd2l-1.0.0/pyd2l.egg-info/dependency_links.txt +1 -0
- pyd2l-1.0.0/pyd2l.egg-info/requires.txt +7 -0
- pyd2l-1.0.0/pyd2l.egg-info/top_level.txt +1 -0
- pyd2l-1.0.0/pyd2l.egg-info/zip-safe +1 -0
- pyd2l-1.0.0/pyproject.toml +3 -0
- pyd2l-1.0.0/setup.cfg +4 -0
- pyd2l-1.0.0/setup.py +52 -0
pyd2l-1.0.0/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "{}"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright {yyyy} {name of copyright owner}
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
pyd2l-1.0.0/MANIFEST.in
ADDED
pyd2l-1.0.0/PKG-INFO
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: pyd2l
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Extension of d2l (Dive into Deep Learning) for newer PyTorch compatibility
|
|
5
|
+
Home-page: https://d2l.ai
|
|
6
|
+
Author: A student in ML
|
|
7
|
+
License: MIT-0
|
|
8
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
9
|
+
Classifier: Intended Audience :: Developers
|
|
10
|
+
Classifier: Intended Audience :: Education
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
13
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
14
|
+
Requires-Python: >=3.5
|
|
15
|
+
Description-Content-Type: text/markdown
|
|
16
|
+
License-File: pyd2l/LICENSE
|
|
17
|
+
Requires-Dist: numpy
|
|
18
|
+
Requires-Dist: pandas
|
|
19
|
+
Requires-Dist: matplotlib
|
|
20
|
+
Requires-Dist: requests
|
|
21
|
+
Requires-Dist: Pillow
|
|
22
|
+
Requires-Dist: torch
|
|
23
|
+
Requires-Dist: torchvision
|
|
24
|
+
Dynamic: author
|
|
25
|
+
Dynamic: classifier
|
|
26
|
+
Dynamic: description
|
|
27
|
+
Dynamic: description-content-type
|
|
28
|
+
Dynamic: home-page
|
|
29
|
+
Dynamic: license
|
|
30
|
+
Dynamic: license-file
|
|
31
|
+
Dynamic: requires-dist
|
|
32
|
+
Dynamic: requires-python
|
|
33
|
+
Dynamic: summary
|
|
34
|
+
|
|
35
|
+
# pyd2l
|
|
36
|
+
|
|
37
|
+
**pyd2l** 是 [《动手学深度学习》](https://d2l.ai)(Dive into Deep Learning,d2l)库的扩展包,专注于解决在新版 PyTorch 环境下的 ABI 与环境适配问题,使书中代码在各类版本组合下都能顺畅安装、运行而不报错。
|
|
38
|
+
|
|
39
|
+
## 为什么需要 pyd2l
|
|
40
|
+
|
|
41
|
+
原始 `d2l` 包在 `install_requires` 中锁定了较旧的依赖版本(如 `numpy==1.24`、`matplotlib==3.5.1`、`pandas==1.2.4` 等),这会导致:
|
|
42
|
+
|
|
43
|
+
- 在较新的 Python / PyTorch / NumPy 环境下安装时产生版本冲突
|
|
44
|
+
- 与用户已有的新版科学计算栈不兼容
|
|
45
|
+
- 因 ABI 不匹配(尤其涉及编译扩展的包)而报错
|
|
46
|
+
|
|
47
|
+
`pyd2l` 通过**解除版本锁**来最大化环境兼容性:所有依赖均不锁定版本号,pip 不会覆盖用户已安装的包,从而适配尽可能多的版本组合。
|
|
48
|
+
|
|
49
|
+
## 安装
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
pip install pyd2l
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
如果你已经装好 PyTorch(含对应的 CUDA / CPU 版本),pyd2l 不会覆盖它——它只确保其余依赖(numpy、pandas、matplotlib 等)就位。
|
|
56
|
+
|
|
57
|
+
## 使用方法
|
|
58
|
+
|
|
59
|
+
pyd2l 的 API 与 `d2l.torch` 完全一致,可作为直接替代:
|
|
60
|
+
|
|
61
|
+
```python
|
|
62
|
+
from pyd2l import torch as d2l
|
|
63
|
+
|
|
64
|
+
d2l.use_svg_display()
|
|
65
|
+
d2l.set_figsize((6, 4))
|
|
66
|
+
|
|
67
|
+
# 与书中示例相同的调用方式
|
|
68
|
+
X = d2l.tensor([1.0, 2.0, 3.0])
|
|
69
|
+
print(d2l.numpy(X))
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
所有 `d2l.torch` 中的函数(`DATA_HUB`、`DATA_URL`、`plot`、`Timer`、`Accumulator`、`Animator`、训练循环工具等)均可在 pyd2l 中以相同方式调用。
|
|
73
|
+
|
|
74
|
+
## 与 d2l 的关系
|
|
75
|
+
|
|
76
|
+
| | d2l | pyd2l |
|
|
77
|
+
|---|---|---|
|
|
78
|
+
| 依赖版本 | 锁定旧版 | 不锁定,自适应 |
|
|
79
|
+
| PyTorch 适配 | 面向旧版 torch | 面向新版 torch |
|
|
80
|
+
| 安装冲突 | 常见 | 已缓解 |
|
|
81
|
+
| API | — | 完全兼容 d2l.torch |
|
|
82
|
+
|
|
83
|
+
pyd2l 在 d2l 的基础上扩展开发,保留了原库全部功能,重点改进了环境适配能力。
|
|
84
|
+
|
|
85
|
+
## 依赖
|
|
86
|
+
|
|
87
|
+
以下依赖均**不锁定版本**,由用户的运行环境决定:
|
|
88
|
+
|
|
89
|
+
- `torch`
|
|
90
|
+
- `torchvision`
|
|
91
|
+
- `numpy`
|
|
92
|
+
- `pandas`
|
|
93
|
+
- `matplotlib`
|
|
94
|
+
- `requests`
|
|
95
|
+
- `Pillow`
|
|
96
|
+
|
|
97
|
+
## 许可证
|
|
98
|
+
|
|
99
|
+
MIT-0(MIT No Attribution),与 d2l 代码部分一致。
|
pyd2l-1.0.0/README.md
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# 动手学深度学习(Dive into Deep Learning,D2L.ai)
|
|
2
|
+
|
|
3
|
+
[](http://ci.d2l.ai/job/d2l-zh/job/master/)
|
|
4
|
+
|
|
5
|
+
[第二版:zh.D2L.ai](https://zh.d2l.ai) | [第一版:zh-v1.D2L.ai](https://zh-v1.d2l.ai/) | 安装和使用书中源代码: [第二版](https://zh.d2l.ai/chapter_installation/index.html) [第一版](https://zh-v1.d2l.ai/chapter_prerequisite/install.html)
|
|
6
|
+
|
|
7
|
+
<h5 align="center"><i>理解深度学习的最佳方法是学以致用。</i></h5>
|
|
8
|
+
|
|
9
|
+
<p align="center">
|
|
10
|
+
<img width="200" src="static/frontpage/_images/eq.jpg">
|
|
11
|
+
<img width="200" src="static/frontpage/_images/figure.jpg">
|
|
12
|
+
<img width="200" src="static/frontpage/_images/code.jpg">
|
|
13
|
+
<img width="200" src="static/frontpage/_images/notebook.gif">
|
|
14
|
+
</p>
|
|
15
|
+
|
|
16
|
+
本开源项目代表了我们的一种尝试:我们将教给读者概念、背景知识和代码;我们将在同一个地方阐述剖析问题所需的批判性思维、解决问题所需的数学知识,以及实现解决方案所需的工程技能。
|
|
17
|
+
|
|
18
|
+
我们的目标是创建一个为实现以下目标的统一资源:
|
|
19
|
+
1. 所有人均可在网上免费获取;
|
|
20
|
+
1. 提供足够的技术深度,从而帮助读者实际成为深度学习应用科学家:既理解数学原理,又能够实现并不断改进方法;
|
|
21
|
+
1. 包含可运行的代码,为读者展示如何在实际中解决问题。这样不仅直接将数学公式对应成实际代码,而且可以修改代码、观察结果并及时获取经验;
|
|
22
|
+
1. 允许我们和整个社区不断快速迭代内容,从而紧跟仍在高速发展的深度学习领域;
|
|
23
|
+
1. 由包含有关技术细节问答的论坛作为补充,使大家可以相互答疑并交换经验。
|
|
24
|
+
|
|
25
|
+
<h5 align="center">将本书(中英文版)用作教材或参考书的大学</h5>
|
|
26
|
+
<p align="center">
|
|
27
|
+
<img width="400" src="https://d2l.ai/_images/map.png">
|
|
28
|
+
</p>
|
|
29
|
+
|
|
30
|
+
如果本书对你有帮助,请Star (★) 本仓库或引用本书的英文版:
|
|
31
|
+
|
|
32
|
+
```
|
|
33
|
+
@article{zhang2021dive,
|
|
34
|
+
title={Dive into Deep Learning},
|
|
35
|
+
author={Zhang, Aston and Lipton, Zachary C. and Li, Mu and Smola, Alexander J.},
|
|
36
|
+
journal={arXiv preprint arXiv:2106.11342},
|
|
37
|
+
year={2021}
|
|
38
|
+
}
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## 本书的英文版
|
|
42
|
+
|
|
43
|
+
虽然纸质书已出版,但深度学习领域依然在迅速发展。为了得到来自更广泛的英文开源社区的帮助,从而提升本书质量,本书的新版将继续用英文编写,并搬回中文版。
|
|
44
|
+
|
|
45
|
+
欢迎关注本书的[英文开源项目](https://github.com/d2l-ai/d2l-en)。
|
|
46
|
+
|
|
47
|
+
## 中英文教学资源
|
|
48
|
+
|
|
49
|
+
加州大学伯克利分校 2019 年春学期 [*Introduction to Deep Learning* 课程](http://courses.d2l.ai/berkeley-stat-157/index.html)教材(同时提供含教学视频地址的[中文版课件](https://github.com/d2l-ai/berkeley-stat-157/tree/master/slides-zh))。
|
|
50
|
+
|
|
51
|
+
## 学术界推荐
|
|
52
|
+
|
|
53
|
+
> <p>"Dive into this book if you want to dive into deep learning!"</p>
|
|
54
|
+
> <b>— 韩家炜,ACM 院士、IEEE 院士,美国伊利诺伊大学香槟分校计算机系 Michael Aiken Chair 教授</b>
|
|
55
|
+
|
|
56
|
+
> <p>"This is a highly welcome addition to the machine learning literature."</p>
|
|
57
|
+
> <b>— Bernhard Schölkopf,ACM 院士、德国国家科学院院士,德国马克斯•普朗克研究所智能系统院院长</b>
|
|
58
|
+
|
|
59
|
+
> <p>"书中代码可谓‘所学即所用’。"</p>
|
|
60
|
+
> <b>— 周志华,ACM 院士、IEEE 院士、AAAS 院士,南京大学计算机科学与技术系主任</b>
|
|
61
|
+
|
|
62
|
+
> <p>"这本书可以帮助深度学习实践者快速提升自己的能力。"</p>
|
|
63
|
+
> <b>— 张潼,ASA 院士、IMS 院士,香港科技大学计算机系和数学系教授</b>
|
|
64
|
+
|
|
65
|
+
## 工业界推荐
|
|
66
|
+
|
|
67
|
+
> <p>"一本优秀的深度学习教材,值得任何想了解深度学习何以引爆人工智能革命的人关注。"</p>
|
|
68
|
+
> <b>— 黄仁勋,NVIDIA创始人 & CEO</b>
|
|
69
|
+
|
|
70
|
+
> <p>"《动手学深度学习》是最适合工业界研发工程师学习的。我毫无保留地向广大的读者们强烈推荐。"</p>
|
|
71
|
+
> <b>— 余凯,地平线公司创始人 & CEO</b>
|
|
72
|
+
|
|
73
|
+
> <p>"强烈推荐这本书!我特别赞赏这种手脑一体的学习方式。"</p>
|
|
74
|
+
> <b>— 漆远,复旦大学“浩清”教授、人工智能创新与产业研究院院长</b>
|
|
75
|
+
|
|
76
|
+
> <p>"《动手学深度学习》是一本很容易让学习者上瘾的书。"</p>
|
|
77
|
+
> <b>— 沈强,将门创投创始合伙人</b>
|
|
78
|
+
|
|
79
|
+
## 贡献
|
|
80
|
+
|
|
81
|
+
感谢[社区贡献者们](https://github.com/d2l-ai/d2l-zh/graphs/contributors)为每一位读者改进这本开源书。
|
|
82
|
+
|
|
83
|
+
[如何贡献](https://zh.d2l.ai/chapter_appendix-tools-for-deep-learning/contributing.html) | [致谢](https://zh.d2l.ai/chapter_preface/index.html) | [讨论或报告问题](https://discuss.d2l.ai/c/chinese-version/16) | [其他](INFO.md)
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
MIT No Attribution
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 p2l contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
|
6
|
+
software and associated documentation files (the "Software"), to deal in the Software
|
|
7
|
+
without restriction, including without limitation the rights to use, copy, modify,
|
|
8
|
+
merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
|
|
9
|
+
permit persons to whom the Software is furnished to do so.
|
|
10
|
+
|
|
11
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
|
12
|
+
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
|
13
|
+
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
14
|
+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
15
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
16
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# pyd2l
|
|
2
|
+
|
|
3
|
+
**pyd2l** 是 [《动手学深度学习》](https://d2l.ai)(Dive into Deep Learning,d2l)库的扩展包,专注于解决在新版 PyTorch 环境下的 ABI 与环境适配问题,使书中代码在各类版本组合下都能顺畅安装、运行而不报错。
|
|
4
|
+
|
|
5
|
+
## 为什么需要 pyd2l
|
|
6
|
+
|
|
7
|
+
原始 `d2l` 包在 `install_requires` 中锁定了较旧的依赖版本(如 `numpy==1.24`、`matplotlib==3.5.1`、`pandas==1.2.4` 等),这会导致:
|
|
8
|
+
|
|
9
|
+
- 在较新的 Python / PyTorch / NumPy 环境下安装时产生版本冲突
|
|
10
|
+
- 与用户已有的新版科学计算栈不兼容
|
|
11
|
+
- 因 ABI 不匹配(尤其涉及编译扩展的包)而报错
|
|
12
|
+
|
|
13
|
+
`pyd2l` 通过**解除版本锁**来最大化环境兼容性:所有依赖均不锁定版本号,pip 不会覆盖用户已安装的包,从而适配尽可能多的版本组合。
|
|
14
|
+
|
|
15
|
+
## 安装
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
pip install pyd2l
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
如果你已经装好 PyTorch(含对应的 CUDA / CPU 版本),pyd2l 不会覆盖它——它只确保其余依赖(numpy、pandas、matplotlib 等)就位。
|
|
22
|
+
|
|
23
|
+
## 使用方法
|
|
24
|
+
|
|
25
|
+
pyd2l 的 API 与 `d2l.torch` 完全一致,可作为直接替代:
|
|
26
|
+
|
|
27
|
+
```python
|
|
28
|
+
from pyd2l import torch as d2l
|
|
29
|
+
|
|
30
|
+
d2l.use_svg_display()
|
|
31
|
+
d2l.set_figsize((6, 4))
|
|
32
|
+
|
|
33
|
+
# 与书中示例相同的调用方式
|
|
34
|
+
X = d2l.tensor([1.0, 2.0, 3.0])
|
|
35
|
+
print(d2l.numpy(X))
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
所有 `d2l.torch` 中的函数(`DATA_HUB`、`DATA_URL`、`plot`、`Timer`、`Accumulator`、`Animator`、训练循环工具等)均可在 pyd2l 中以相同方式调用。
|
|
39
|
+
|
|
40
|
+
## 与 d2l 的关系
|
|
41
|
+
|
|
42
|
+
| | d2l | pyd2l |
|
|
43
|
+
|---|---|---|
|
|
44
|
+
| 依赖版本 | 锁定旧版 | 不锁定,自适应 |
|
|
45
|
+
| PyTorch 适配 | 面向旧版 torch | 面向新版 torch |
|
|
46
|
+
| 安装冲突 | 常见 | 已缓解 |
|
|
47
|
+
| API | — | 完全兼容 d2l.torch |
|
|
48
|
+
|
|
49
|
+
pyd2l 在 d2l 的基础上扩展开发,保留了原库全部功能,重点改进了环境适配能力。
|
|
50
|
+
|
|
51
|
+
## 依赖
|
|
52
|
+
|
|
53
|
+
以下依赖均**不锁定版本**,由用户的运行环境决定:
|
|
54
|
+
|
|
55
|
+
- `torch`
|
|
56
|
+
- `torchvision`
|
|
57
|
+
- `numpy`
|
|
58
|
+
- `pandas`
|
|
59
|
+
- `matplotlib`
|
|
60
|
+
- `requests`
|
|
61
|
+
- `Pillow`
|
|
62
|
+
|
|
63
|
+
## 许可证
|
|
64
|
+
|
|
65
|
+
MIT-0(MIT No Attribution),与 d2l 代码部分一致。
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"""Saved source code for "Dive into Deep Learing" (https://d2l.ai).
|
|
2
|
+
|
|
3
|
+
Please import d2l by one of the following ways:
|
|
4
|
+
|
|
5
|
+
from d2l import mxnet as d2l # Use MXNet as the backend
|
|
6
|
+
from d2l import torch as d2l # Use PyTorch as the backend
|
|
7
|
+
from d2l import tensorflow as d2l # Use TensorFlow as the backend
|
|
8
|
+
from d2l import paddle as d2l # Use Paddle as the backend
|
|
9
|
+
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
__version__ = "1.0.0"
|