forked from open-mmlab/mmocr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsatrn_small.py
73 lines (65 loc) · 1.83 KB
/
satrn_small.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
_base_ = [
'../../_base_/default_runtime.py',
'../../_base_/recog_pipelines/satrn_pipeline.py',
'../../_base_/recog_datasets/ST_MJ_train.py',
'../../_base_/recog_datasets/academic_test.py',
'../../_base_/schedules/schedule_adam_step_6e.py',
]
train_list = {{_base_.train_list}}
test_list = {{_base_.test_list}}
train_pipeline = {{_base_.train_pipeline}}
test_pipeline = {{_base_.test_pipeline}}
max_seq_len = 25
label_convertor = dict(
type='AttnConvertor',
dict_type='DICT90',
with_unknown=True,
max_seq_len=max_seq_len)
model = dict(
type='SATRN',
backbone=dict(type='ShallowCNN', input_channels=3, hidden_dim=256),
encoder=dict(
type='SatrnEncoder',
n_layers=6,
n_head=8,
d_k=256 // 8,
d_v=256 // 8,
d_model=256,
n_position=100,
d_inner=256 * 4,
dropout=0.1),
decoder=dict(
type='NRTRDecoder',
n_layers=6,
d_embedding=256,
n_head=8,
d_model=256,
d_inner=256 * 4,
d_k=256 // 8,
d_v=256 // 8),
loss=dict(type='TFLoss'),
label_convertor=label_convertor,
max_seq_len=max_seq_len)
# optimizer
optimizer = dict(type='Adam', lr=3e-4)
optimizer_config = dict(grad_clip=None)
# learning policy
lr_config = dict(policy='step', step=[3, 4])
data = dict(
samples_per_gpu=64,
workers_per_gpu=4,
val_dataloader=dict(samples_per_gpu=1),
test_dataloader=dict(samples_per_gpu=1),
train=dict(
type='UniformConcatDataset',
datasets=train_list,
pipeline=train_pipeline),
val=dict(
type='UniformConcatDataset',
datasets=test_list,
pipeline=test_pipeline),
test=dict(
type='UniformConcatDataset',
datasets=test_list,
pipeline=test_pipeline))
evaluation = dict(interval=1, metric='acc')