Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
David Maxence
prj_deep
Commits
bec06382
Commit
bec06382
authored
May 05, 2021
by
David Maxence
Browse files
modif
parent
d4319c71
Changes
1
Hide whitespace changes
Inline
Side-by-side
urbanclass_fold.py
View file @
bec06382
...
@@ -75,8 +75,7 @@ def train_test_split(fold_k, data, X_dim=(128, 128, 1)):
...
@@ -75,8 +75,7 @@ def train_test_split(fold_k, data, X_dim=(128, 128, 1)):
def
show_results
(
tot_history
):
def
show_results
(
tot_history
):
"""Show accuracy and loss graphs for train and test sets."""
"""Show accuracy and loss graphs for train and test sets."""
pngName
=
[
'result/res1.png'
,
'result/res2.png'
,
'result/res3.png'
,
'result/res4.png'
,
'result/res5.png'
,
'result/res6.png'
,
'result/res7.png'
,
pngName
=
[
'resultaugmented/res1.png'
,
'resultaugmented/res2.png'
,
'resultaugmented/res3.png'
,
'resultaugmented/res4.png'
,
'resultaugmented/res5.png'
,
'resultaugmented/res6.png'
,
'resultaugmented/res7.png'
,
'resultaugmented/res8.png'
,
'resultaugmented/res9.png'
,
'resultaugmented/res10.png'
]
'result/res8.png'
,
'result/res9.png'
,
'result/res10.png'
]
for
i
,
history
in
enumerate
(
tot_history
):
for
i
,
history
in
enumerate
(
tot_history
):
print
(
'
\n
({})'
.
format
(
i
+
1
))
print
(
'
\n
({})'
.
format
(
i
+
1
))
fig
=
plt
.
figure
()
fig
=
plt
.
figure
()
...
@@ -100,8 +99,8 @@ def show_results(tot_history):
...
@@ -100,8 +99,8 @@ def show_results(tot_history):
plt
.
savefig
(
pngName
[
i
])
plt
.
savefig
(
pngName
[
i
])
file
=
open
(
'result/result.txt'
,
'a'
)
file
=
open
(
'result
augmented
/result.txt'
,
'a'
)
file
.
write
(
'
\n
=========FOLD%s=========
\n
'
%
i
+
1
)
file
.
write
(
'
\n
=========FOLD%s=========
\n
'
%
(
i
+
1
)
)
file
.
write
(
'
\n
Max validation accuracy: %.4f %%'
%
(
np
.
max
(
history
.
history
[
'val_accuracy'
])
*
100
))
file
.
write
(
'
\n
Max validation accuracy: %.4f %%'
%
(
np
.
max
(
history
.
history
[
'val_accuracy'
])
*
100
))
file
.
write
(
'
\n
Min validation loss: %.5f'
%
np
.
min
(
history
.
history
[
'val_loss'
]))
file
.
write
(
'
\n
Min validation loss: %.5f'
%
np
.
min
(
history
.
history
[
'val_loss'
]))
...
@@ -117,7 +116,7 @@ def process_fold(fold_k, data, epochs=100, num_batch_size=32):
...
@@ -117,7 +116,7 @@ def process_fold(fold_k, data, epochs=100, num_batch_size=32):
model
=
init_model
()
model
=
init_model
()
# pre-training accuracy
# pre-training accuracy
log_dir
=
"logs/fit/"
+
datetime
.
now
().
strftime
(
"%Y%m%d-%H%M%S"
)
log_dir
=
"logs/fit/
folds/
"
+
datetime
.
now
().
strftime
(
"%Y%m%d-%H%M%S"
)
tensorboard_callback
=
tf
.
keras
.
callbacks
.
TensorBoard
(
log_dir
=
log_dir
,
histogram_freq
=
1
)
tensorboard_callback
=
tf
.
keras
.
callbacks
.
TensorBoard
(
log_dir
=
log_dir
,
histogram_freq
=
1
)
...
@@ -130,7 +129,7 @@ def process_fold(fold_k, data, epochs=100, num_batch_size=32):
...
@@ -130,7 +129,7 @@ def process_fold(fold_k, data, epochs=100, num_batch_size=32):
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
us8k_df
=
pd
.
read_pickle
(
"us8k_df.pkl"
)
us8k_df
=
pd
.
read_pickle
(
"us8k_
augmented_
df.pkl"
)
history1
=
[]
history1
=
[]
for
i
in
range
(
10
)
:
for
i
in
range
(
10
)
:
FOLD
=
i
+
1
FOLD
=
i
+
1
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment