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
454c87bd
Commit
454c87bd
authored
2 years ago
by
tomrink
Browse files
Options
Downloads
Patches
Plain Diff
snapshot...
parent
94349b40
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
modules/deeplearning/srcnn_l1b_l2.py
+78
-0
78 additions, 0 deletions
modules/deeplearning/srcnn_l1b_l2.py
with
78 additions
and
0 deletions
modules/deeplearning/srcnn_l1b_l2.py
+
78
−
0
View file @
454c87bd
import
glob
import
glob
import
tensorflow
as
tf
import
tensorflow
as
tf
import
util.util
from
util.setup
import
logdir
,
modeldir
,
cachepath
,
now
,
ancillary_path
from
util.setup
import
logdir
,
modeldir
,
cachepath
,
now
,
ancillary_path
from
util.util
import
EarlyStop
,
normalize
,
denormalize
,
resample
,
resample_2d_linear
,
resample_one
,
\
from
util.util
import
EarlyStop
,
normalize
,
denormalize
,
resample
,
resample_2d_linear
,
resample_one
,
\
resample_2d_linear_one
,
get_grid_values_all
,
add_noise
,
smooth_2d
,
smooth_2d_single
resample_2d_linear_one
,
get_grid_values_all
,
add_noise
,
smooth_2d
,
smooth_2d_single
...
@@ -766,6 +768,82 @@ def run_evaluate_static(in_file, out_file, ckpt_dir):
...
@@ -766,6 +768,82 @@ def run_evaluate_static(in_file, out_file, ckpt_dir):
return
out_sr
,
hr_grd_a
,
hr_grd_c
return
out_sr
,
hr_grd_a
,
hr_grd_c
def
analyze
(
file
=
'
/Users/tomrink/cld_opd_out.npy
'
):
# Save this:
# nn.test_data_files = glob.glob('/Users/tomrink/data/clavrx_opd_valid_DAY/data_valid*.npy')
# idxs = np.arange(50)
# dat, lbl = nn.get_in_mem_data_batch(idxs, False)
# tmp = dat[:, 1:128, 1:128, 1]
# tmp = dat[:, 1:129, 1:129, 1]
tup
=
np
.
load
(
file
,
allow_pickle
=
True
)
lbls
=
tup
[
0
]
pred
=
tup
[
1
]
lbls
=
lbls
[:,
:,
:,
0
]
pred
=
pred
[:,
:,
:,
0
]
diff
=
pred
-
lbls
mae
=
(
np
.
sum
(
np
.
abs
(
diff
)))
/
diff
.
size
print
(
'
MAE:
'
,
mae
)
bin_ranges
=
util
.
util
.
get_bin_ranges
(
0.0
,
160.0
,
20.0
)
bin_edges
=
[]
bin_ranges
=
[]
bin_ranges
.
append
([
0.0
,
5.0
])
bin_edges
.
append
(
0.0
)
bin_ranges
.
append
([
5.0
,
10.0
])
bin_edges
.
append
(
5.0
)
bin_ranges
.
append
([
10.0
,
15.0
])
bin_edges
.
append
(
10.0
)
bin_ranges
.
append
([
15.0
,
20.0
])
bin_edges
.
append
(
15.0
)
bin_ranges
.
append
([
20.0
,
30.0
])
bin_edges
.
append
(
20.0
)
bin_ranges
.
append
([
30.0
,
40.0
])
bin_edges
.
append
(
30.0
)
bin_ranges
.
append
([
40.0
,
60.0
])
bin_edges
.
append
(
40.0
)
bin_ranges
.
append
([
60.0
,
80.0
])
bin_edges
.
append
(
60.0
)
bin_ranges
.
append
([
80.0
,
100.0
])
bin_edges
.
append
(
80.0
)
bin_ranges
.
append
([
100.0
,
120.0
])
bin_edges
.
append
(
100.0
)
bin_ranges
.
append
([
120.0
,
140.0
])
bin_edges
.
append
(
120.0
)
bin_ranges
.
append
([
140.0
,
160.0
])
bin_edges
.
append
(
140.0
)
bin_edges
.
append
(
160.0
)
diff_by_value_bins
=
util
.
util
.
bin_data_by
(
diff
.
flatten
(),
lbls
.
flatten
(),
bin_ranges
)
values
=
[]
for
k
in
range
(
len
(
bin_ranges
)):
diff_k
=
diff_by_value_bins
[
k
]
mae_k
=
(
np
.
sum
(
np
.
abs
(
diff_k
))
/
diff_k
.
size
)
values
.
append
(
int
(
mae_k
/
bin_ranges
[
k
][
1
]
*
100.0
))
print
(
'
MAE:
'
,
diff_k
.
size
,
bin_ranges
[
k
],
mae_k
)
return
np
.
array
(
values
),
bin_edges
if
__name__
==
"
__main__
"
:
if
__name__
==
"
__main__
"
:
nn
=
SRCNN
()
nn
=
SRCNN
()
nn
.
run
(
'
matchup_filename
'
)
nn
.
run
(
'
matchup_filename
'
)
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