Skip to content

Commit

Permalink
【PaddlePaddle】Update nadaraya-waston.md & Adjust warnings (d2l-ai#1218)
Browse files Browse the repository at this point in the history
* Update nadaraya-waston.md

* Change warning location

* Add warning filter to index.md

* Test warnings of d2l.paddle

* Adjust warnings

* Optimize warnings

* Update chapter_convolutional-modern warnings
  • Loading branch information
w5688414 authored Nov 9, 2022
1 parent 318d0e3 commit 7f4c68d
Show file tree
Hide file tree
Showing 87 changed files with 168 additions and 228 deletions.
3 changes: 1 addition & 2 deletions chapter_attention-mechanisms/attention-cues.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,10 @@ import tensorflow as tf

```{.python .input}
#@tab paddle
from d2l import paddle as d2l
import warnings
warnings.filterwarnings("ignore")
import paddle
warnings.filterwarnings("ignore", category=DeprecationWarning)
from d2l import paddle as d2l
```

为了可视化注意力权重,需要定义一个`show_heatmaps`函数。
Expand Down
5 changes: 2 additions & 3 deletions chapter_attention-mechanisms/attention-scoring-functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,12 @@ import tensorflow as tf

```{.python .input}
#@tab paddle
import warnings
from d2l import paddle as d2l
import math
import warnings
warnings.filterwarnings("ignore")
import paddle
from paddle import nn
warnings.filterwarnings("ignore", category=DeprecationWarning)
from d2l import paddle as d2l
```

## [**掩蔽softmax操作**]
Expand Down
4 changes: 2 additions & 2 deletions chapter_attention-mechanisms/bahdanau-attention.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,11 @@ import tensorflow as tf

```{.python .input}
#@tab paddle
from d2l import paddle as d2l
import warnings
warnings.filterwarnings("ignore")
import paddle
from paddle import nn
warnings.filterwarnings("ignore", category=DeprecationWarning)
from d2l import paddle as d2l
```

## 定义注意力解码器
Expand Down
5 changes: 2 additions & 3 deletions chapter_attention-mechanisms/multihead-attention.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,12 @@ import tensorflow as tf

```{.python .input}
#@tab paddle
from d2l import paddle as d2l
import warnings
import math
warnings.filterwarnings("ignore")
import math
import paddle
from paddle import nn
warnings.filterwarnings("ignore", category=DeprecationWarning)
from d2l import paddle as d2l
```

## 实现
Expand Down
5 changes: 2 additions & 3 deletions chapter_attention-mechanisms/nadaraya-waston.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,11 @@ tf.random.set_seed(seed=1322)

```{.python .input}
#@tab paddle
from d2l import paddle as d2l
import warnings
warnings.filterwarnings("ignore")
import paddle
from paddle import nn
warnings.filterwarnings("ignore", category=DeprecationWarning)
from d2l import paddle as d2l
```

## [**生成数据集**]
Expand Down Expand Up @@ -121,7 +120,7 @@ def f(x):
return 2 * paddle.sin(x) + x**0.8
y_train = f(x_train) + paddle.normal(0.0, 0.5, (n_train,)) # 训练样本的输出
x_test = d2l.arange(0, 50, 1) * 0.1 # 测试样本
x_test = d2l.arange(0, 5, 0.1, dtype='float32') # 测试样本
y_truth = f(x_test) # 测试样本的真实输出
n_test = len(x_test) # 测试样本数
n_test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,12 @@ import tensorflow as tf

```{.python .input}
#@tab paddle
import warnings
from d2l import paddle as d2l
import math
import warnings
warnings.filterwarnings("ignore")
import paddle
from paddle import nn
warnings.filterwarnings("ignore", category=DeprecationWarning)
from d2l import paddle as d2l
```

## [**自注意力**]
Expand Down
5 changes: 2 additions & 3 deletions chapter_attention-mechanisms/transformer.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,13 @@ import tensorflow as tf

```{.python .input}
#@tab paddle
import warnings
from d2l import paddle as d2l
import math
import pandas as pd
import warnings
warnings.filterwarnings("ignore")
import paddle
from paddle import nn
warnings.filterwarnings("ignore", category=DeprecationWarning)
from d2l import paddle as d2l
```

## [**基于位置的前馈网络**]
Expand Down
6 changes: 3 additions & 3 deletions chapter_computational-performance/async-computation.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ from torch import nn

```{.python .input}
#@tab paddle
import warnings
from d2l import paddle as d2l
import numpy, os, subprocess
import warnings
warnings.filterwarnings("ignore")
import paddle
from paddle import nn
warnings.filterwarnings("ignore", category=DeprecationWarning)
from d2l import paddle as d2l
d2l.try_gpu()
```

Expand Down
4 changes: 2 additions & 2 deletions chapter_computational-performance/auto-parallelism.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ import torch

```{.python .input}
#@tab paddle
from d2l import paddle as d2l
import warnings
warnings.filterwarnings("ignore")
import paddle
import numpy as np
warnings.filterwarnings("ignore", category=DeprecationWarning)
from d2l import paddle as d2l
```

## 基于GPU的并行计算
Expand Down
6 changes: 2 additions & 4 deletions chapter_computational-performance/hybridize.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,16 +154,14 @@ net(x)

```{.python .input}
#@tab paddle
from d2l import paddle as d2l
import warnings
warnings.filterwarnings('ignore')
warnings.filterwarnings("ignore")
import paddle
from paddle import nn
from paddle.jit import to_static
from paddle.static import InputSpec
warnings.filterwarnings("ignore")
from d2l import paddle as d2l
# 生产网络的工厂模式
def get_net():
blocks = [
Expand Down
4 changes: 2 additions & 2 deletions chapter_computational-performance/multiple-gpus-concise.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ from torch import nn

```{.python .input}
#@tab paddle
from d2l import paddle as d2l
import warnings
warnings.filterwarnings("ignore")
import paddle
from paddle import nn
warnings.filterwarnings("ignore", category=DeprecationWarning)
from d2l import paddle as d2l
```

## [**简单网络**]
Expand Down
4 changes: 2 additions & 2 deletions chapter_computational-performance/multiple-gpus.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,12 @@ from torch.nn import functional as F
```{.python .input}
#@tab paddle
%matplotlib inline
from d2l import paddle as d2l
import warnings
warnings.filterwarnings("ignore")
import paddle
from paddle import nn
from paddle.nn import functional as F
warnings.filterwarnings("ignore", category=DeprecationWarning)
from d2l import paddle as d2l
```

## [**简单网络**]
Expand Down
3 changes: 1 addition & 2 deletions chapter_computer-vision/anchor.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,11 @@ torch.set_printoptions(2) # 精简输出精度
```{.python .input}
#@tab paddle
%matplotlib inline
from d2l import paddle as d2l
import warnings
warnings.filterwarnings("ignore")
import paddle
import numpy as np
warnings.filterwarnings("ignore", category=DeprecationWarning)
from d2l import paddle as d2l
paddle.set_printoptions(2) # 精简输出精度
```
Expand Down
3 changes: 1 addition & 2 deletions chapter_computer-vision/bounding-box.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,10 @@ import tensorflow as tf
```{.python .input}
#@tab paddle
%matplotlib inline
from d2l import paddle as d2l
import warnings
warnings.filterwarnings("ignore")
import paddle
warnings.filterwarnings("ignore", category=DeprecationWarning)
from d2l import paddle as d2l
```

下面加载本节将使用的示例图像。可以看到图像左边是一只狗,右边是一只猫。
Expand Down
3 changes: 1 addition & 2 deletions chapter_computer-vision/fcn.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,13 @@ from torch.nn import functional as F
```{.python .input}
#@tab paddle
%matplotlib inline
from d2l import paddle as d2l
import warnings
warnings.filterwarnings("ignore")
import paddle
from paddle import nn
from paddle.nn import functional as F
warnings.filterwarnings("ignore", category=DeprecationWarning)
import paddle.vision as paddlevision
from d2l import paddle as d2l
```

## 构造模型
Expand Down
4 changes: 2 additions & 2 deletions chapter_computer-vision/fine-tuning.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,13 @@ import os
```{.python .input}
#@tab paddle
%matplotlib inline
from d2l import paddle as d2l
import warnings
warnings.filterwarnings("ignore")
from paddle import nn
import paddle
import paddle.vision as paddlevision
import os
warnings.filterwarnings("ignore", category=DeprecationWarning)
from d2l import paddle as d2l
```

### 获取数据集
Expand Down
3 changes: 1 addition & 2 deletions chapter_computer-vision/image-augmentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,12 @@ from torch import nn
```{.python .input}
#@tab paddle
%matplotlib inline
from d2l import paddle as d2l
import warnings
warnings.filterwarnings("ignore")
import paddle
import paddle.vision as paddlevision
from paddle import nn
warnings.filterwarnings("ignore", category=DeprecationWarning)
from d2l import paddle as d2l
```

## 常用的图像增广方法
Expand Down
5 changes: 2 additions & 3 deletions chapter_computer-vision/kaggle-cifar10.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,17 @@ import shutil

```{.python .input}
#@tab paddle
from d2l import paddle as d2l
import warnings
warnings.filterwarnings("ignore")
import collections
import math
import os
import pandas as pd
import shutil
warnings.filterwarnings("ignore")
import paddle
from paddle import nn
warnings.filterwarnings("ignore", category=DeprecationWarning)
import paddle.vision as paddlevision
from d2l import paddle as d2l
```

## 获取并组织数据集
Expand Down
4 changes: 2 additions & 2 deletions chapter_computer-vision/kaggle-dog.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ import os

```{.python .input}
#@tab paddle
from d2l import paddle as d2l
import warnings
warnings.filterwarnings("ignore")
import paddle
import paddle.vision as paddlevision
from paddle import nn
import os
warnings.filterwarnings("ignore", category=DeprecationWarning)
from d2l import paddle as d2l
```

## 获取和整理数据集
Expand Down
3 changes: 1 addition & 2 deletions chapter_computer-vision/multiscale-object-detection.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,10 @@ h, w
```{.python .input}
#@tab paddle
%matplotlib inline
from d2l import paddle as d2l
import warnings
warnings.filterwarnings("ignore")
import paddle
warnings.filterwarnings("ignore", category=DeprecationWarning)
from d2l import paddle as d2l
img = d2l.plt.imread('../img/catdog.jpg')
h, w = img.shape[:2]
Expand Down
4 changes: 1 addition & 3 deletions chapter_computer-vision/neural-style.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,10 @@ d2l.plt.imshow(content_img);
```{.python .input}
#@tab paddle
%matplotlib inline
import warnings
from d2l import paddle as d2l
import paddle
import paddle.vision as paddlevision
import paddle.nn as nn
warnings.filterwarnings("ignore", category=DeprecationWarning)
from d2l import paddle as d2l
d2l.set_figsize()
content_img = d2l.Image.open('../img/rainier.jpg')
Expand Down
5 changes: 2 additions & 3 deletions chapter_computer-vision/object-detection-dataset.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,13 @@ import pandas as pd
```{.python .input}
#@tab paddle
%matplotlib inline
from d2l import paddle as d2l
import warnings
warnings.filterwarnings("ignore")
import os
import pandas as pd
warnings.filterwarnings("ignore")
import paddle
warnings.filterwarnings("ignore", category=DeprecationWarning)
import paddle.vision as paddlevision
from d2l import paddle as d2l
```

```{.python .input}
Expand Down
3 changes: 1 addition & 2 deletions chapter_computer-vision/semantic-segmentation-and-dataset.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,12 @@ import os
```{.python .input}
#@tab paddle
%matplotlib inline
from d2l import paddle as d2l
import warnings
warnings.filterwarnings("ignore")
import paddle
import paddle.vision as paddlevision
import os
warnings.filterwarnings("ignore", category=DeprecationWarning)
from d2l import paddle as d2l
```

数据集的tar文件大约为2GB,所以下载可能需要一段时间。
Expand Down
3 changes: 1 addition & 2 deletions chapter_computer-vision/ssd.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,13 @@ def cls_predictor(num_inputs, num_anchors, num_classes):
```{.python .input}
#@tab paddle
%matplotlib inline
from d2l import paddle as d2l
import warnings
warnings.filterwarnings("ignore")
import paddle
from paddle import nn
from paddle.nn import functional as F
import paddle.vision as paddlevision
warnings.filterwarnings("ignore", category=DeprecationWarning)
from d2l import paddle as d2l
def cls_predictor(num_inputs, num_anchors, num_classes):
return nn.Conv2D(num_inputs, num_anchors * (num_classes + 1),
Expand Down
5 changes: 1 addition & 4 deletions chapter_computer-vision/transposed-conv.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,9 @@ from d2l import torch as d2l

```{.python .input}
#@tab paddle
import warnings
warnings.filterwarnings("ignore")
from d2l import paddle as d2l
import paddle
from paddle import nn
warnings.filterwarnings("ignore", category=DeprecationWarning)
from d2l import paddle as d2l
```

## 基本操作
Expand Down
Loading

0 comments on commit 7f4c68d

Please sign in to comment.