Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
Climax
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
earth_observation_public
Climax
Commits
85e41d45
Commit
85e41d45
authored
3 years ago
by
Frisinghelli Daniel
Browse files
Options
Downloads
Patches
Plain Diff
Implemented first version of downscaling script.
parent
65165449
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
climax/main/config.py
+14
-0
14 additions, 0 deletions
climax/main/config.py
climax/main/downscale.py
+28
-9
28 additions, 9 deletions
climax/main/downscale.py
with
42 additions
and
9 deletions
climax/main/config.py
+
14
−
0
View file @
85e41d45
...
...
@@ -75,3 +75,17 @@ SHUFFLE = False
# batch size: number of time steps processed by the net in each iteration
BATCH_SIZE
=
64
# learning rate
LR
=
0.001
# network training configuration
TRAIN_CONFIG
=
{
'
checkpoint_state
'
:
{},
'
epochs
'
:
50
,
'
save
'
:
True
,
'
early_stop
'
:
True
,
'
patience
'
:
25
,
'
multi_gpu
'
:
True
,
'
classification
'
:
False
}
This diff is collapsed.
Click to expand it.
climax/main/downscale.py
+
28
−
9
View file @
85e41d45
...
...
@@ -3,7 +3,11 @@
# !/usr/bin/env python
# -*- coding: utf-8 -*-
# builtins
from
logging.config
import
dictConfig
# externals
import
torch
import
xarray
as
xr
from
sklearn.model_selection
import
train_test_split
from
torch.utils.data
import
DataLoader
...
...
@@ -11,15 +15,20 @@ from torch.utils.data import DataLoader
# locals
from
pysegcnn.core.utils
import
search_files
from
pysegcnn.core.models
import
SegNet
from
pysegcnn.core.trainer
import
NetworkTrainer
from
pysegcnn.core.logging
import
log_conf
from
climax.core.dataset
import
ERA5Dataset
,
NetCDFDataset
from
climax.core.constants
import
(
ERA5_P_VARIABLES
,
ERA5_S_VARIABLES
,
ERA5_VARIABLES
)
from
climax.core.constants
import
ERA5_VARIABLES
from
climax.main.config
import
(
ERA5_PATH
,
ERA5_PLEVELS
,
OBS_PATH
,
PREDICTAND
,
CALIB_PERIOD
,
MODEL_PATH
,
SHUFFLE
,
BATCH_SIZE
)
CALIB_PERIOD
,
MODEL_PATH
,
SHUFFLE
,
BATCH_SIZE
,
LR
,
TRAIN_CONFIG
)
if
__name__
==
'
__main__
'
:
# initialize logging
dictConfig
(
log_conf
())
# initialize ERA5 predictor dataset
Era5
=
ERA5Dataset
(
ERA5_PATH
.
joinpath
(
'
ERA5
'
),
ERA5_VARIABLES
,
plevels
=
ERA5_PLEVELS
)
...
...
@@ -45,10 +54,20 @@ if __name__ == '__main__':
valid_dl
=
DataLoader
(
valid_ds
,
batch_size
=
BATCH_SIZE
,
shuffle
=
SHUFFLE
,
drop_last
=
False
)
# initialize network: calculate number of input variables
in_channels
=
int
(
len
(
ERA5_P_VARIABLES
)
*
len
(
ERA5_PLEVELS
)
+
len
(
ERA5_S_VARIABLES
))
net
=
SegNet
(
MODEL_PATH
.
joinpath
(
PREDICTAND
+
'
.pt
'
),
in_channels
,
1
)
# initialize network
net
=
SegNet
(
MODEL_PATH
.
joinpath
(
PREDICTAND
+
'
.pt
'
),
len
(
Era5_ds
.
data_vars
),
1
)
# initialize optimizer
optimizer
=
torch
.
optim
.
Adam
(
net
.
parameters
(),
lr
=
LR
)
# initialize loss function
loss_function
=
torch
.
nn
.
MSELoss
()
# initialize network trainer
trainer
=
NetworkTrainer
(
net
,
optimizer
,
net
.
state_file
,
train_dl
,
valid_dl
,
loss_function
=
loss_function
,
**
TRAIN_CONFIG
)
#
initialize network training
# TODO: Extend ClassificationNetworkTrainer -> RegressionNetworkT
rain
er
#
train model
state
=
trainer
.
t
rain
()
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