Skip to content

Commit 612dcb6

Browse files
authored
Update pytorch.md
1 parent c0a3246 commit 612dcb6

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

pytorch.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,16 @@ tensor([[3, 8],
4141
```python
4242
#d loss_fn / d w = (d loss_fn / d t_p) * (d t_p / d w)
4343
```
44+
45+
## Use neural network to fit the data
46+
- curve is caused by activation function, such as nn.Tanh()
47+
- neural network has a tendency to overfit.
48+
- optim.SGD: Stochastic Gradient Descent(随机梯度下降) 为了批量优化
49+
50+
tips:
51+
how to control the color of matplotlib
52+
```python
53+
plt.plot(t_u.numpy(), t_c.numpy(), 'o', color='red')
54+
plt.plot(t_range.numpy(), seq_model(0.1 * t_range).detach().numpy(), 'c-')
55+
plt.plot(t_u.numpy(), seq_model(0.1 * t_u).detach().numpy(), 'kx')
56+
```

0 commit comments

Comments
 (0)