Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
combo
Manage
Activity
Members
Labels
Plan
Issues
20
Issue boards
Milestones
Wiki
Redmine
Code
Merge requests
2
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Syntactic Tools
combo
Commits
ed29c7a0
Commit
ed29c7a0
authored
1 year ago
by
Martyna Wiącek
Browse files
Options
Downloads
Patches
Plain Diff
add setting random seed
parent
f0811ea2
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!50
Fix imports and random seed
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
combo/main.py
+13
-0
13 additions, 0 deletions
combo/main.py
with
13 additions
and
0 deletions
combo/main.py
+
13
−
0
View file @
ed29c7a0
...
...
@@ -4,8 +4,10 @@ import os
import
pathlib
import
tempfile
from
itertools
import
chain
import
random
from
typing
import
Dict
,
Optional
,
Any
,
Tuple
import
numpy.random.bit_generator
import
torch
from
absl
import
app
,
flags
import
pytorch_lightning
as
pl
...
...
@@ -47,6 +49,7 @@ flags.DEFINE_integer(name="n_cuda_devices", default=-1,
help
=
"
Number of devices to train on (default -1 auto mode - train on as many as possible)
"
)
flags
.
DEFINE_string
(
name
=
"
output_file
"
,
default
=
"
output.log
"
,
help
=
"
Predictions result file.
"
)
flags
.
DEFINE_integer
(
name
=
"
seed
"
,
default
=
None
,
help
=
"
Random seed.
"
)
# Training flags
flags
.
DEFINE_string
(
name
=
"
training_data_path
"
,
default
=
""
,
help
=
"
Training data path(s)
"
)
...
...
@@ -293,7 +296,17 @@ def read_model_from_config(logging_prefix: str) -> Optional[
return
model
,
dataset_reader
,
training_data_loader
,
validation_data_loader
,
vocabulary
def
set_seed
(
seed
:
int
)
->
None
:
random
.
seed
(
seed
)
numpy
.
random
.
seed
(
seed
)
torch
.
manual_seed
(
seed
)
def
run
(
_
):
if
FLAGS
.
seed
:
set_seed
(
FLAGS
.
seed
)
if
FLAGS
.
mode
==
'
train
'
:
model
,
dataset_reader
,
training_data_loader
,
validation_data_loader
,
vocabulary
=
None
,
None
,
None
,
None
,
None
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
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