Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
combo
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Redmine
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Syntactic Tools
combo
Commits
7210dc10
Commit
7210dc10
authored
May 28, 2020
by
Mateusz Klimaszewski
Browse files
Options
Downloads
Patches
Plain Diff
Make tensorboard metrics lighter, group output file config flags.
parent
d9dd119c
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
combo/data/dataset.py
+2
-0
2 additions, 0 deletions
combo/data/dataset.py
combo/main.py
+4
-6
4 additions, 6 deletions
combo/main.py
combo/models/base.py
+2
-1
2 additions, 1 deletion
combo/models/base.py
config.template.jsonnet
+3
-2
3 additions, 2 deletions
config.template.jsonnet
with
11 additions
and
9 deletions
combo/data/dataset.py
+
2
−
0
View file @
7210dc10
...
@@ -46,6 +46,8 @@ class UniversalDependenciesDatasetReader(allen_data.DatasetReader):
...
@@ -46,6 +46,8 @@ class UniversalDependenciesDatasetReader(allen_data.DatasetReader):
fields
=
list
(
parser
.
DEFAULT_FIELDS
)
fields
=
list
(
parser
.
DEFAULT_FIELDS
)
fields
[
1
]
=
'
token
'
# use 'token' instead of 'form'
fields
[
1
]
=
'
token
'
# use 'token' instead of 'form'
field_parsers
=
parser
.
DEFAULT_FIELD_PARSERS
field_parsers
=
parser
.
DEFAULT_FIELD_PARSERS
# Do not make it nullable
field_parsers
.
pop
(
'
xpostag
'
,
None
)
if
self
.
_use_sem
:
if
self
.
_use_sem
:
fields
=
list
(
fields
)
fields
=
list
(
fields
)
fields
.
append
(
'
semrel
'
)
fields
.
append
(
'
semrel
'
)
...
...
This diff is collapsed.
Click to expand it.
combo/main.py
+
4
−
6
View file @
7210dc10
...
@@ -25,6 +25,8 @@ flags.DEFINE_enum(name='mode', default=None, enum_values=['train', 'predict'],
...
@@ -25,6 +25,8 @@ flags.DEFINE_enum(name='mode', default=None, enum_values=['train', 'predict'],
# Common flags
# Common flags
flags
.
DEFINE_integer
(
name
=
'
cuda_device
'
,
default
=-
1
,
flags
.
DEFINE_integer
(
name
=
'
cuda_device
'
,
default
=-
1
,
help
=
"
Cuda device id (default -1 cpu)
"
)
help
=
"
Cuda device id (default -1 cpu)
"
)
flags
.
DEFINE_string
(
name
=
'
output_file
'
,
default
=
'
output.log
'
,
help
=
'
Predictions result file.
'
)
# Training flags
# Training flags
flags
.
DEFINE_list
(
name
=
'
training_data_path
'
,
default
=
"
./tests/fixtures/example.conllu
"
,
flags
.
DEFINE_list
(
name
=
'
training_data_path
'
,
default
=
"
./tests/fixtures/example.conllu
"
,
...
@@ -60,8 +62,6 @@ flags.DEFINE_string(name='config_path', default='config.template.jsonnet',
...
@@ -60,8 +62,6 @@ flags.DEFINE_string(name='config_path', default='config.template.jsonnet',
help
=
'
Config file path.
'
)
help
=
'
Config file path.
'
)
# Test after training flags
# Test after training flags
flags
.
DEFINE_string
(
name
=
'
result
'
,
default
=
'
result.conllu
'
,
help
=
'
Test result path file
'
)
flags
.
DEFINE_string
(
name
=
'
test_path
'
,
default
=
None
,
flags
.
DEFINE_string
(
name
=
'
test_path
'
,
default
=
None
,
help
=
'
Test path file.
'
)
help
=
'
Test path file.
'
)
...
@@ -74,8 +74,6 @@ flags.DEFINE_string(name='model_path', default=None,
...
@@ -74,8 +74,6 @@ flags.DEFINE_string(name='model_path', default=None,
help
=
'
Pretrained model path.
'
)
help
=
'
Pretrained model path.
'
)
flags
.
DEFINE_string
(
name
=
'
input_file
'
,
default
=
None
,
flags
.
DEFINE_string
(
name
=
'
input_file
'
,
default
=
None
,
help
=
'
File to predict path
'
)
help
=
'
File to predict path
'
)
flags
.
DEFINE_string
(
name
=
'
output_file
'
,
default
=
'
output.log
'
,
help
=
'
Predictions result file.
'
)
flags
.
DEFINE_integer
(
name
=
'
batch_size
'
,
default
=
1
,
flags
.
DEFINE_integer
(
name
=
'
batch_size
'
,
default
=
1
,
help
=
'
Prediction batch size.
'
)
help
=
'
Prediction batch size.
'
)
flags
.
DEFINE_boolean
(
name
=
'
silent
'
,
default
=
True
,
flags
.
DEFINE_boolean
(
name
=
'
silent
'
,
default
=
True
,
...
@@ -126,7 +124,7 @@ def run(_):
...
@@ -126,7 +124,7 @@ def run(_):
logger
.
info
(
f
'
Finetuned model stored in:
{
serialization_dir
}
'
)
logger
.
info
(
f
'
Finetuned model stored in:
{
serialization_dir
}
'
)
if
FLAGS
.
test_path
and
FLAGS
.
result
:
if
FLAGS
.
test_path
and
FLAGS
.
output_file
:
checks
.
file_exists
(
FLAGS
.
test_path
)
checks
.
file_exists
(
FLAGS
.
test_path
)
params
=
common
.
Params
.
from_file
(
FLAGS
.
config_path
,
ext_vars
=
_get_ext_vars
())[
'
dataset_reader
'
]
params
=
common
.
Params
.
from_file
(
FLAGS
.
config_path
,
ext_vars
=
_get_ext_vars
())[
'
dataset_reader
'
]
params
.
pop
(
'
type
'
)
params
.
pop
(
'
type
'
)
...
@@ -137,7 +135,7 @@ def run(_):
...
@@ -137,7 +135,7 @@ def run(_):
)
)
test_path
=
FLAGS
.
test_path
test_path
=
FLAGS
.
test_path
test_trees
=
dataset_reader
.
read
(
test_path
)
test_trees
=
dataset_reader
.
read
(
test_path
)
with
open
(
FLAGS
.
result
,
'
w
'
)
as
f
:
with
open
(
FLAGS
.
output_file
,
'
w
'
)
as
f
:
for
tree
in
test_trees
:
for
tree
in
test_trees
:
f
.
writelines
(
predictor
.
predict_instance_as_tree
(
tree
).
serialize
())
f
.
writelines
(
predictor
.
predict_instance_as_tree
(
tree
).
serialize
())
else
:
else
:
...
...
This diff is collapsed.
Click to expand it.
combo/models/base.py
+
2
−
1
View file @
7210dc10
...
@@ -102,7 +102,8 @@ class FeedForwardPredictor(Predictor):
...
@@ -102,7 +102,8 @@ class FeedForwardPredictor(Predictor):
"
len(hidden_dims) (%d) + 1 != num_layers (%d)
"
%
(
len
(
hidden_dims
),
num_layers
)
"
len(hidden_dims) (%d) + 1 != num_layers (%d)
"
%
(
len
(
hidden_dims
),
num_layers
)
)
)
assert
vocab_namespace
in
vocab
.
get_namespaces
()
assert
vocab_namespace
in
vocab
.
get_namespaces
(),
\
f
"
There is not
{
vocab_namespace
}
in created vocabs, check if this field has any values to predict!
"
hidden_dims
=
hidden_dims
+
[
vocab
.
get_vocab_size
(
vocab_namespace
)]
hidden_dims
=
hidden_dims
+
[
vocab
.
get_vocab_size
(
vocab_namespace
)]
return
cls
(
feedforward
.
FeedForward
(
return
cls
(
feedforward
.
FeedForward
(
...
...
This diff is collapsed.
Click to expand it.
config.template.jsonnet
+
3
−
2
View file @
7210dc10
...
@@ -364,8 +364,9 @@ assert pretrained_tokens == null || pretrained_transformer_name == null: "Can't
...
@@ -364,8 +364,9 @@ assert pretrained_tokens == null || pretrained_transformer_name == null: "Can't
},
},
tensorboard_writer
:
{
tensorboard_writer
:
{
serialization_dir
:
metrics_dir
,
serialization_dir
:
metrics_dir
,
should_log_learning_rate
:
true
,
should_log_learning_rate
:
false
,
summary_interval
:
2
,
should_log_parameter_statistics
:
false
,
summary_interval
:
100
,
},
},
validation_metric
:
"+EM"
,
validation_metric
:
"+EM"
,
},
},
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment