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
84556761
Commit
84556761
authored
3 years ago
by
tomrink
Browse files
Options
Downloads
Patches
Plain Diff
snapshot...
parent
4f329b22
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/icing_cnn.py
+14
-8
14 additions, 8 deletions
modules/deeplearning/icing_cnn.py
with
14 additions
and
8 deletions
modules/deeplearning/icing_cnn.py
+
14
−
8
View file @
84556761
...
...
@@ -9,6 +9,7 @@ import pickle
import
h5py
from
icing.pirep_goes
import
split_data
,
normalize
from
util.plot_cm
import
plot_confusion_matrix
LOG_DEVICE_PLACEMENT
=
False
...
...
@@ -240,12 +241,13 @@ class IcingIntensityNN:
dataset
=
dataset
.
map
(
self
.
data_function
,
num_parallel_calls
=
8
)
self
.
test_dataset
=
dataset
def
setup_pipeline
(
self
,
filename
):
def
setup_pipeline
(
self
,
filename
,
trn_idxs
=
None
,
tst_idxs
=
None
):
self
.
filename
=
filename
self
.
h5f
=
h5py
.
File
(
filename
,
'
r
'
)
time
=
self
.
h5f
[
'
time
'
]
num_obs
=
time
.
shape
[
0
]
trn_idxs
,
tst_idxs
=
split_data
(
num_obs
)
if
trn_idxs
is
None
and
tst_idxs
is
None
:
time
=
self
.
h5f
[
'
time
'
]
num_obs
=
time
.
shape
[
0
]
trn_idxs
,
tst_idxs
=
split_data
(
num_obs
)
self
.
num_data_samples
=
trn_idxs
.
shape
[
0
]
self
.
get_train_dataset
(
trn_idxs
)
...
...
@@ -464,7 +466,7 @@ class IcingIntensityNN:
t_loss
=
self
.
loss
(
labels
,
pred
)
self
.
test_labels
.
append
(
labels
)
self
.
test_preds
.
append
(
pred
.
result
().
numpy
())
self
.
test_preds
.
append
(
pred
.
numpy
())
self
.
test_loss
(
t_loss
)
self
.
test_accuracy
(
labels
,
pred
)
...
...
@@ -594,9 +596,13 @@ class IcingIntensityNN:
for
mini_batch_test
in
ds
:
self
.
predict
(
mini_batch_test
)
print
(
'
loss, acc:
'
,
self
.
test_loss
.
result
(),
self
.
test_accuracy
.
result
())
cm
=
tf
.
math
.
confusion_matrix
(
np
.
concatenate
(
self
.
test_labels
),
np
.
concatenate
(
self
.
test_preds
),
num_classes
=
2
)
cm
=
cm
.
result
().
numpy
()
print
(
cm
)
labels
=
np
.
concatenate
(
self
.
test_labels
)
preds
=
np
.
concatenate
(
self
.
test_preds
)
preds
=
np
.
where
(
preds
>
0.5
,
1
,
0
)
self
.
test_labels
=
labels
self
.
test_preds
=
preds
def
run
(
self
,
filename
,
filename_l1b
=
None
):
with
tf
.
device
(
'
/device:GPU:
'
+
str
(
self
.
gpu_device
)):
...
...
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