Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
python
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
Tom Rink
python
Commits
cab215cf
Commit
cab215cf
authored
2 years ago
by
tomrink
Browse files
Options
Downloads
Patches
Plain Diff
snapshot...
parent
9782049a
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
modules/deeplearning/cnn_cld_frac_mod_res.py
+6
-30
6 additions, 30 deletions
modules/deeplearning/cnn_cld_frac_mod_res.py
with
6 additions
and
30 deletions
modules/deeplearning/cnn_cld_frac_mod_res.py
+
6
−
30
View file @
cab215cf
...
@@ -40,7 +40,6 @@ DO_AUGMENT = True
...
@@ -40,7 +40,6 @@ DO_AUGMENT = True
DO_SMOOTH
=
False
DO_SMOOTH
=
False
SIGMA
=
1.0
SIGMA
=
1.0
DO_ZERO_OUT
=
False
DO_ZERO_OUT
=
False
DO_ESPCN
=
False
# Note: If True, cannot do mixed resolution input fields (Adjust accordingly below)
# setup scaling parameters dictionary
# setup scaling parameters dictionary
mean_std_dct
=
{}
mean_std_dct
=
{}
...
@@ -103,12 +102,6 @@ elif KERNEL_SIZE == 5:
...
@@ -103,12 +102,6 @@ elif KERNEL_SIZE == 5:
x_2
=
np
.
arange
(
68
)
x_2
=
np
.
arange
(
68
)
y_2
=
np
.
arange
(
68
)
y_2
=
np
.
arange
(
68
)
# ----------------------------------------
# ----------------------------------------
# Exp for ESPCN version
if
DO_ESPCN
:
slc_x_2
=
slice
(
0
,
132
,
2
)
slc_y_2
=
slice
(
0
,
132
,
2
)
x_128
=
slice
(
2
,
130
)
y_128
=
slice
(
2
,
130
)
def
build_residual_conv2d_block
(
conv
,
num_filters
,
block_name
,
activation
=
tf
.
nn
.
relu
,
padding
=
'
SAME
'
,
def
build_residual_conv2d_block
(
conv
,
num_filters
,
block_name
,
activation
=
tf
.
nn
.
relu
,
padding
=
'
SAME
'
,
...
@@ -340,10 +333,7 @@ class SRCNN:
...
@@ -340,10 +333,7 @@ class SRCNN:
idx
=
params
.
index
(
param
)
idx
=
params
.
index
(
param
)
tmp
=
input_data
[:,
idx
,
:,
:]
tmp
=
input_data
[:,
idx
,
:,
:]
tmp
=
tmp
.
copy
()
tmp
=
tmp
.
copy
()
if
DO_ESPCN
:
tmp
=
tmp
[:,
slc_y
,
slc_x
]
tmp
=
tmp
[:,
slc_y_2
,
slc_x_2
]
else
:
tmp
=
tmp
[:,
slc_y
,
slc_x
]
tmp
=
normalize
(
tmp
,
param
,
mean_std_dct
)
tmp
=
normalize
(
tmp
,
param
,
mean_std_dct
)
data_norm
.
append
(
tmp
)
data_norm
.
append
(
tmp
)
...
@@ -365,16 +355,12 @@ class SRCNN:
...
@@ -365,16 +355,12 @@ class SRCNN:
# ---------------------------------------------------
# ---------------------------------------------------
tmp
=
input_data
[:,
label_idx
,
:,
:]
tmp
=
input_data
[:,
label_idx
,
:,
:]
tmp
=
tmp
.
copy
()
tmp
=
tmp
.
copy
()
if
DO_ESPCN
:
tmp
=
tmp
[:,
slc_y
,
slc_x
]
tmp
=
tmp
[:,
slc_y_2
,
slc_x_2
]
else
:
tmp
=
tmp
[:,
slc_y
,
slc_x
]
if
label_param
!=
'
cloud_probability
'
:
tmp
=
normalize
(
tmp
,
label_param
,
mean_std_dct
)
data_norm
.
append
(
tmp
)
data_norm
.
append
(
tmp
)
# ---------
# ---------
data
=
np
.
stack
(
data_norm
,
axis
=
3
)
data
=
np
.
stack
(
data_norm
,
axis
=
3
)
data
=
data
.
astype
(
np
.
float32
)
data
=
data
.
astype
(
np
.
float32
)
# -----------------------------------------------------
# -----------------------------------------------------
# -----------------------------------------------------
# -----------------------------------------------------
label
=
input_label
[:,
label_idx_i
,
:,
:]
label
=
input_label
[:,
label_idx_i
,
:,
:]
...
@@ -385,10 +371,7 @@ class SRCNN:
...
@@ -385,10 +371,7 @@ class SRCNN:
else
:
else
:
label
=
get_label_data
(
label
)
label
=
get_label_data
(
label
)
if
label_param
!=
'
cloud_probability
'
:
label
=
np
.
where
(
np
.
isnan
(
label
),
0
,
label
)
label
=
normalize
(
label
,
label_param
,
mean_std_dct
)
else
:
label
=
np
.
where
(
np
.
isnan
(
label
),
0
,
label
)
label
=
np
.
expand_dims
(
label
,
axis
=
3
)
label
=
np
.
expand_dims
(
label
,
axis
=
3
)
data
=
data
.
astype
(
np
.
float32
)
data
=
data
.
astype
(
np
.
float32
)
...
@@ -519,15 +502,8 @@ class SRCNN:
...
@@ -519,15 +502,8 @@ class SRCNN:
else
:
else
:
final_activation
=
tf
.
nn
.
softmax
# For multi-class
final_activation
=
tf
.
nn
.
softmax
# For multi-class
if
not
DO_ESPCN
:
# This is effectively a Dense layer
# This is effectively a Dense layer
self
.
logits
=
tf
.
keras
.
layers
.
Conv2D
(
NumLogits
,
kernel_size
=
1
,
strides
=
1
,
padding
=
padding
,
activation
=
final_activation
)(
conv
)
self
.
logits
=
tf
.
keras
.
layers
.
Conv2D
(
NumLogits
,
kernel_size
=
1
,
strides
=
1
,
padding
=
padding
,
activation
=
final_activation
)(
conv
)
else
:
conv
=
tf
.
keras
.
layers
.
Conv2D
(
num_filters
*
(
factor
**
2
),
3
,
padding
=
padding
,
activation
=
activation
)(
conv
)
print
(
conv
.
shape
)
conv
=
tf
.
nn
.
depth_to_space
(
conv
,
factor
)
print
(
conv
.
shape
)
self
.
logits
=
tf
.
keras
.
layers
.
Conv2D
(
IMG_DEPTH
,
kernel_size
=
3
,
strides
=
1
,
padding
=
padding
,
activation
=
final_activation
)(
conv
)
print
(
self
.
logits
.
shape
)
print
(
self
.
logits
.
shape
)
def
build_training
(
self
):
def
build_training
(
self
):
...
...
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