提交 2c597dec 编写于 作者: W wizardforcel

2021-01-16 12:48:50

上级 aad850df
......@@ -38,11 +38,11 @@
代码块设置如下:
进口火炬
导入 torch.optim 作为优化
导入 matplotlib.pyplot 作为 plt
```py
import torch
import torch.optim as optim
import matplotlib.pyplot as plt
```
这样显示了新术语和重要单词:“本章还将探讨**自然语言处理****NLP**)的概念。”
......@@ -52,31 +52,31 @@
例如:
历史= model.fit(X,y,历元= 100,batch_size = 5,详细= 1,\
validate_split = 0.2,随机播放= False)
```py
history = model.fit(X, y, epochs=100, batch_size=5, verbose=1, \
                   validation_split=0.2, shuffle=False)
```
注释已添加到代码中,以帮助解释特定的逻辑位。 单行注释使用`#`符号表示,如下所示:
#打印数据集的大小
print(“数据集中的示例数=”,X.shape [0])
print(“每个示例的功能数量=”,X.shape [1])
```py
# Print the sizes of the dataset
print("Number of Examples in the Dataset = ", X.shape[0])
print("Number of Features for each example = ", X.shape[1])
```
多行注释用三引号引起来,如下所示:
```py
"""
为随机数生成器定义种子,以确保结果可重复
Define a seed for the random number generator to ensure the result will be reproducible
"""
种子= 1
np.random.seed(种子)
random.set_seed(种子)
seed = 1
np.random.seed(seed)
random.set_seed(seed)
```
## 硬件要求
......@@ -116,7 +116,9 @@ random.set_seed(种子)
1. Open your Terminal and type the following command:
须藤 apt-get install python3.7
```py
sudo apt-get install python3.7
```
您还可以使用 Anaconda 发行版安装 Python。 [请遵循此链接中给出的说明以获取更多详细信息](https://www.anaconda.com/products/individual)。
......@@ -124,16 +126,20 @@ random.set_seed(种子)
Python 3.7 的安装默认包含`pip`。 但是,可能是没有安装的情况。 要检查它是否已安装,请在终端或命令提示符下执行以下命令:
```py
pip --version
```
由于计算机上的`pip`先前版本已经使用`pip`命令,因此您可能需要使用`pip3`命令。
如果您的计算机无法识别`pip`(或`pip3`)命令,请按照以下步骤进行安装:
1. 要安装`pip`[请访问以下链接并下载 **get-pip.py** 文件](https://pip.pypa.io/en/stable/installing/)
1. 要安装`pip`,[请访问以下链接并下载`get-pip.py`文件](https://pip.pypa.io/en/stable/installing/)。
2. Then, on the Terminal or Command Prompt, use the following command to install it:
```py
python get-pip.py
```
由于您机器上的 Python 先前版本已使用`python`命令,因此您可能需要使用`python3 get-pip.py`命令。
......@@ -157,7 +163,9 @@ pip --version
2. 在“终端/命令提示符”中,转到您下载了该书的 GitHub 存储库的目录位置。
3. Open a Jupyter Notebook by typing in the following command:
jupyter 笔记本
```py
jupyter notebook
```
通过执行前面的命令,您将能够通过计算机的默认浏览器使用 Jupyter Notebook。
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册