Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 3575751

Browse files
author
xyliao
committed
fix readme
1 parent 3ffe6aa commit 3575751

File tree

5 files changed

+66
-16
lines changed

5 files changed

+66
-16
lines changed

‎README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ Learn Deep Learning with PyTorch
7575
### part2: 深度学习的应用
7676
- Chapter 9: 计算机视觉
7777
- [Fine-tuning: 通过微调进行迁移学习](https://github.com/SherlockLiao/code-of-learn-deep-learning-with-pytorch/blob/master/chapter9_Computer-Vision/fine_tune/fine-tune.ipynb)
78-
- [语义分割: 通过 FCN 实现像素级别的分类](https://github.com/SherlockLiao/code-of-learn-deep-learning-with-pytorch/blob/master/chapter9_Computer-Vision/segmentation/fcn.ipynb)
78+
- [语义分割: 通过 FCN 实现像素级别的分类](https://github.com/SherlockLiao/code-of-learn-deep-learning-with-pytorch/tree/master/chapter9_Computer-Vision/segmentation)
7979
- Pixel to Pixel 生成对抗网络
8080
- Neural Transfer: 通过卷积网络实现风格迁移
8181
- Deep Dream: 探索卷积网络眼中的世界
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
## Fine Tune 教程
2+
3+
### Requirements
4+
5+
[PyTorch 0.3](http://pytorch.org/)
6+
7+
[MxTorch](https://github.com/SherlockLiao/mxtorch)
8+
9+
[tensorboardX](https://github.com/lanpa/tensorboard-pytorch)
10+
11+
按照 pytorch 官网安装 pytorch,将 mxtorch 下载下来,放到根目录,安装 tensorboardX 实现 tensorboard 可视化
12+
13+
```bash
14+
\fine_tune
15+
\mxtorch
16+
\hymenoptera_data
17+
\train
18+
\val
19+
\checkpoints
20+
config.py
21+
main.py
22+
get_data.sh
23+
```
24+
25+
26+
27+
### 下载数据
28+
29+
打开终端,运行 bash 脚本来获取数据
30+
31+
```bash
32+
bash get_data.sh
33+
```
34+
35+
36+
37+
### 训练模型
38+
39+
所有的配置文件都放在 config.py 里面,通过下面的代码来训练模型
40+
41+
```bash
42+
python main.py train
43+
```
44+
45+
也可以在终端修改配置,比如改变 epochs 和 batch_size
46+
47+
```bash
48+
python main.py train \
49+
--max_epochs=100 \
50+
--batch_size=16
51+
```
52+
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Download data.
2+
wget https://download.pytorch.org/tutorial/hymenoptera_data.zip
3+
4+
unzip hymenoptera_data.zip

‎chapter9_Computer-Vision/segmentation/README.md‎

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66

77
[MxTorch](https://github.com/SherlockLiao/mxtorch)
88

9-
[tensorboardX](https://github.com/lanpa/tensorboard-pytorch) (optional)
9+
[tensorboardX](https://github.com/lanpa/tensorboard-pytorch)
1010

11-
按照 pytorch 官网安装 pytorch,将 mxtorch 下载下来,放到根目录,同时可以安装 tensorboardX 实现 tensorboard 可视化
11+
按照 pytorch 官网安装 pytorch,将 mxtorch 下载下来,放到根目录,安装 tensorboardX 实现 tensorboard 可视化
1212

1313
```bash
1414
\segmentation
@@ -37,26 +37,18 @@ bash get_data.sh
3737

3838
所有的配置文件都放在 config.py 里面,通过下面的代码来训练模型
3939

40-
```python
40+
```bash
4141
python main.py train
4242
```
4343

4444
也可以在终端修改配置,比如改变 epochs 和 batch_size
4545

46-
```python
46+
```bash
4747
python main.py train \
4848
--max_epochs=100 \
4949
--batch_size=16
5050
```
5151

52-
#### 可选
53-
54-
如果安装了 tensorboardX,则可以使用 tensorboard 可视化,通过
55-
56-
```bash
57-
python main.py train --vis_dir='./vis'
58-
```
59-
6052

6153

6254
### 训练效果

‎chapter9_Computer-Vision/segmentation/config.py‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class DefaultConfig(object):
2222
save_best = True # If save best test metric model.
2323

2424
# Visualization parameters.
25-
# vis_dir = './vis/'
25+
vis_dir = './vis/'
2626
plot_freq = 30 # plot in tensorboard every N iterations
2727

2828
# Model hyperparameters.
@@ -47,8 +47,10 @@ def _parse(self, kwargs):
4747
print('============end===============')
4848

4949
def _state_dict(self):
50-
return {k: getattr(self, k) for k, _ in DefaultConfig.__dict__.items()
51-
if not k.startswith('_')}
50+
return {
51+
k: getattr(self, k)
52+
for k, _ in DefaultConfig.__dict__.items() if not k.startswith('_')
53+
}
5254

5355

5456
opt = DefaultConfig()

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /