1. Import **torch**, the **optim** package from PyTorch, and **matplotlib**:
进口火炬
导入 torch.optim 作为优化
导入 matplotlib.pyplot 作为 plt
```py
import torch
import torch.optim as optim
import matplotlib.pyplot as plt
```
2. Create dummy input data (`x`) of random values and dummy target data (`y`) that only contains zeros and ones. Tensor`x`should have a size of (**20,10**), while the size of`y`should be (**20,1**):
x = torch.randn(20,10)
y = torch.randint(0,2,(20,1))。type(torch.FloatTensor)
```py
x = torch.randn(20,10)
y = torch.randint(0,2, (20,1)).type(torch.FloatTensor)
```
3. Define the optimization algorithm as the Adam optimizer. Set the learning rate equal to`0.01`: