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
fc3d456d
Commit
fc3d456d
authored
2 years ago
by
tomrink
Browse files
Options
Downloads
Patches
Plain Diff
deal with bigger data
parent
ea55efe4
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/unet_l1b_l2.py
+38
-21
38 additions, 21 deletions
modules/deeplearning/unet_l1b_l2.py
with
38 additions
and
21 deletions
modules/deeplearning/unet_l1b_l2.py
+
38
−
21
View file @
fc3d456d
...
@@ -13,7 +13,7 @@ import h5py
...
@@ -13,7 +13,7 @@ import h5py
LOG_DEVICE_PLACEMENT
=
False
LOG_DEVICE_PLACEMENT
=
False
PROC_BATCH_SIZE
=
2048
PROC_BATCH_SIZE
=
10
PROC_BATCH_BUFFER_SIZE
=
50000
PROC_BATCH_BUFFER_SIZE
=
50000
NumClasses
=
2
NumClasses
=
2
...
@@ -216,23 +216,38 @@ class UNET:
...
@@ -216,23 +216,38 @@ class UNET:
def
get_in_mem_data_batch
(
self
,
idxs
,
is_training
):
def
get_in_mem_data_batch
(
self
,
idxs
,
is_training
):
np
.
sort
(
idxs
)
np
.
sort
(
idxs
)
dat_files
=
[]
lbl_files
=
[]
if
is_training
:
if
is_training
:
f
=
self
.
train_data_files
for
k
in
idxs
:
nda
=
np
.
load
(
f
)
f
=
self
.
train_data_files
[
k
]
data
=
nda
[
idxs
,
:,
:,
:]
nda
=
np
.
load
(
f
)
dat_files
.
append
(
nda
)
f
=
self
.
train_label_files
[
k
]
nda
=
np
.
load
(
f
)
lbl_files
.
append
(
nda
)
data
=
np
.
concatenate
(
dat_files
)
label
=
np
.
concatenate
(
lbl_files
)
f
=
self
.
train_label_files
label
=
label
[:,
label_idx
,
:,
:]
nda
=
np
.
load
(
f
)
label
=
nda
[
idxs
,
label_idx
,
:,
:]
label
=
np
.
expand_dims
(
label
,
axis
=
3
)
label
=
np
.
expand_dims
(
label
,
axis
=
3
)
else
:
else
:
f
=
self
.
test_data_files
for
k
in
idxs
:
nda
=
np
.
load
(
f
)
f
=
self
.
train_data_files
[
k
]
data
=
nda
[
idxs
,
:,
:,
:]
nda
=
np
.
load
(
f
)
dat_files
.
append
(
nda
)
f
=
self
.
test_label_files
f
=
self
.
train_label_files
[
k
]
nda
=
np
.
load
(
f
)
nda
=
np
.
load
(
f
)
label
=
nda
[
idxs
,
label_idx
,
:,
:]
lbl_files
.
append
(
nda
)
data
=
np
.
concatenate
(
dat_files
)
label
=
np
.
concatenate
(
lbl_files
)
label
=
label
[:,
label_idx
,
:,
:]
label
=
np
.
expand_dims
(
label
,
axis
=
3
)
label
=
np
.
expand_dims
(
label
,
axis
=
3
)
data
=
data
.
astype
(
np
.
float32
)
data
=
data
.
astype
(
np
.
float32
)
...
@@ -363,14 +378,14 @@ class UNET:
...
@@ -363,14 +378,14 @@ class UNET:
self
.
test_data_files
=
test_data_files
self
.
test_data_files
=
test_data_files
self
.
test_label_files
=
test_label_files
self
.
test_label_files
=
test_label_files
trn_idxs
=
np
.
arange
(
20925
)
trn_idxs
=
np
.
arange
(
len
(
train_data_files
)
)
np
.
random
.
shuffle
(
trn_idxs
)
np
.
random
.
shuffle
(
trn_idxs
)
tst_idxs
=
np
.
arange
(
2325
)
tst_idxs
=
np
.
arange
(
len
(
train_data_files
)
)
self
.
get_train_dataset
(
trn_idxs
)
self
.
get_train_dataset
(
trn_idxs
)
self
.
get_test_dataset
(
tst_idxs
)
self
.
get_test_dataset
(
tst_idxs
)
self
.
num_data_samples
=
20925
self
.
num_data_samples
=
56000
# approximately
print
(
'
datetime:
'
,
now
)
print
(
'
datetime:
'
,
now
)
print
(
'
training and test data:
'
)
print
(
'
training and test data:
'
)
...
@@ -880,11 +895,13 @@ class UNET:
...
@@ -880,11 +895,13 @@ class UNET:
self
.
build_evaluation
()
self
.
build_evaluation
()
self
.
do_training
()
self
.
do_training
()
# def run_test(self, directory):
def
run_test
(
self
,
directory
):
# data_files = glob.glob(directory+'l1b_*.npy')
train_data_files
=
glob
.
glob
(
directory
+
'
data_train*.npy
'
)
# label_files = [f.replace('l1b', 'l2') for f in data_files]
valid_data_files
=
glob
.
glob
(
directory
+
'
data_valid*.npy
'
)
def
run_test
(
self
,
train_data_files
,
train_label_files
,
vld_data_files
,
vld_label_files
):
train_label_files
=
glob
.
glob
(
directory
+
'
label_train*.npy
'
)
self
.
setup_pipeline_files
(
train_data_files
,
train_label_files
,
vld_data_files
,
vld_label_files
)
valid_label_files
=
glob
.
glob
(
directory
+
'
label_valid*.npy
'
)
self
.
setup_pipeline_files
(
train_data_files
,
train_label_files
,
valid_data_files
,
valid_label_files
)
self
.
build_model
()
self
.
build_model
()
self
.
build_training
()
self
.
build_training
()
self
.
build_evaluation
()
self
.
build_evaluation
()
...
...
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