Skip to content

Commit 32c5911

Browse files
committed
first commit
0 parents  commit 32c5911

28 files changed

Lines changed: 911 additions & 0 deletions

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# system
2+
*.egg-info/
3+
__pycache__/
4+
*.py[cod]
5+
6+
#user-defined
7+
dataset
8+
_old

LICENCE

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
2+
The MIT License (MIT)
3+
Copyright (c) 2022
4+
Andrea Gemelli
5+
6+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
7+
8+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
9+
10+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
11+

README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Documents 2 Graph
2+
- [Documents 2 Graph](#documents-2-graph)
3+
- [Info](#info)
4+
- [Install](#install)
5+
- [Results](#results)
6+
- [Usage](#usage)
7+
8+
### Info
9+
Library to convert documents to graphs and perform several tasks on different datasets, like KIE on FUNSD.
10+
11+
### Install
12+
```
13+
pip install .
14+
```
15+
16+
### Results
17+
18+
### Usage
19+
1. To train a **GCN** model for **Entity Labeling** on FUNSD (using CPU):
20+
```
21+
python src/main.py
22+
```
23+
24+
2. To test a trained **GCN** model for **Entity Labeling** on FUNSD (using GPU):
25+
```
26+
python src/main.py --gpu 0 --config gcn --test -w output/weights/gcn-1651069965.pt
27+
```

configs/base.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
MODEL:
2+
# which model to use (choose one)
3+
name: GCN # GAT, ...
4+
num_layers: 3
5+
hidden_dim: 64
6+
dropout: 0.
7+
8+
TRAIN:
9+
lr: 0.01
10+
weight_decay: 0.0005
11+
epochs: 1000
12+
batch_size: 1
13+
14+

configs/cv-1650992863.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
INFO:
2+
f1-macro: 0.5423
3+
f1-micro: 0.6211
4+
features: false
5+
split: 0
6+
total_params: 9604
7+
val_loss: 0.7864165306091309
8+
MODEL:
9+
dropout: 0.0
10+
hidden_dim: 64
11+
name: GCN
12+
num_layers: 3
13+
TRAIN:
14+
batch_size: 134
15+
epochs: 1000
16+
lr: 0.01
17+
weight_decay: 0.0005

configs/cv-1651004399.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
INFO:
2+
f1-macro: 0.6133
3+
f1-micro: 0.7326
4+
features: true
5+
split: 0
6+
total_params: 13508
7+
val_loss: 0.5918518304824829
8+
MODEL:
9+
dropout: 0.0
10+
hidden_dim: 64
11+
name: GCN
12+
num_layers: 2
13+
TRAIN:
14+
batch_size: 14
15+
epochs: 1000
16+
lr: 0.01
17+
weight_decay: 0.0005

configs/gcn.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
INFO:
2+
f1-macro: 0.6133
3+
f1-micro: 0.7326
4+
features: true
5+
split: 0
6+
total_params: 13508
7+
val_loss: 0.5918518304824829
8+
MODEL:
9+
dropout: 0.0
10+
hidden_dim: 64
11+
name: GCN
12+
num_layers: 3
13+
TRAIN:
14+
batch_size: 14
15+
epochs: 1000
16+
lr: 0.01
17+
weight_decay: 0.0005

output/results/gcn-1651069965.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"model": "GCN", "net-params": 9604, "features": "bbox", "val-loss": 0.7924164533615112, "f1-scores": [0.5682672628614822, 0.6462555066079295]}

output/results/gcn-1651070043.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"model": "GCN", "net-params": 21892, "features": "text", "val-loss": 0.6191630959510803, "f1-scores": [0.6324179962172749, 0.73568281938326]}

output/weights/cv-1650992863.pt

40.4 KB
Binary file not shown.

0 commit comments

Comments
 (0)