Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Evaluation künstlicher neuronaler Netze für eine OOS-Erkennung
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Container Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Dennis Willers
Evaluation künstlicher neuronaler Netze für eine OOS-Erkennung
Commits
fa31a565
Commit
fa31a565
authored
May 04, 2023
by
Dennis Willers
🏀
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Final Codebasis
parent
db3b17ff
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
15 additions
and
25 deletions
+15
-25
main.py
main.py
+3
-3
config.yaml
ressources/config/config.yaml
+1
-3
pictureHandling.py
src/data/pictureHandling.py
+2
-3
createKNN.py
src/knn/createKNN.py
+1
-2
defineKNN.py
src/knn/defineKNN.py
+3
-5
analyseExcel.py
src/result/analyseExcel.py
+1
-1
createExcelFile.py
src/result/createExcelFile.py
+4
-8
No files found.
main.py
View file @
fa31a565
...
@@ -83,7 +83,7 @@ def run_model(config, config_knn, worksheet, r):
...
@@ -83,7 +83,7 @@ def run_model(config, config_knn, worksheet, r):
test_it
=
get_test_data
(
datagen
,
config
[
"bilder"
][
"knn_path"
])
test_it
=
get_test_data
(
datagen
,
config
[
"bilder"
][
"knn_path"
])
print
(
"Trainiere das Modell"
)
print
(
"Trainiere das Modell"
)
# fit model
# fit model
history
=
fit_model
(
config
,
model
,
train_it
,
test_it
,
callback
)
fit_model
(
config
,
model
,
train_it
,
test_it
,
callback
)
# evaluate model
# evaluate model
print
(
"Evaluiere das Modell"
)
print
(
"Evaluiere das Modell"
)
evaluate_metrics
=
evaluate_model
(
model
,
test_it
,
datagen
,
config
,
config_knn
)
evaluate_metrics
=
evaluate_model
(
model
,
test_it
,
datagen
,
config
,
config_knn
)
...
@@ -97,9 +97,9 @@ def run_model(config, config_knn, worksheet, r):
...
@@ -97,9 +97,9 @@ def run_model(config, config_knn, worksheet, r):
# print("Erstelle den Plot Graphen")
# print("Erstelle den Plot Graphen")
# plot_values(history, config)
# plot_values(history, config)
print
(
"Inhalte in die Excel-Tabelle schreiben"
)
print
(
"Inhalte in die Excel-Tabelle schreiben"
)
worksheet
,
r
=
create_excel_result
(
worksheet
,
r
,
callback
,
config
,
config_knn
,
evaluate_metrics
,
r
=
create_excel_result
(
worksheet
,
r
,
callback
,
config
,
config_knn
,
evaluate_metrics
,
training_duration_model
)
training_duration_model
)
return
worksheet
,
r
,
evaluate_metrics
,
training_duration_model
return
r
,
evaluate_metrics
,
training_duration_model
def
check_if_kombination_is_not_allowed
(
opt
,
act128
,
act2
,
config
):
def
check_if_kombination_is_not_allowed
(
opt
,
act128
,
act2
,
config
):
...
...
ressources/config/config.yaml
View file @
fa31a565
...
@@ -4,13 +4,11 @@ bilder:
...
@@ -4,13 +4,11 @@ bilder:
# original_path: "assets/Bilder/Datengrundlage-Augmentiert/"
# original_path: "assets/Bilder/Datengrundlage-Augmentiert/"
knn_path
:
"
assets/Bilder/AktuelleTrainingsUndTestdaten/"
knn_path
:
"
assets/Bilder/AktuelleTrainingsUndTestdaten/"
knn
:
knn
:
epochs
:
10
epochs
:
2
exception_optimization_method
:
exception_optimization_method
:
[
'
SGD'
,
'
Adam'
]
exception_activation_funktion_2
:
exception_activation_funktion_2
:
[
'
ReLU'
]
[
'
ReLU'
]
ignoreKnnCombinations
:
ignoreKnnCombinations
:
[]
result
:
result
:
plot_path
:
"
ressources/results/plot/"
plot_path
:
"
ressources/results/plot/"
excel_path
:
"
ressources/results/excel/"
excel_path
:
"
ressources/results/excel/"
src/data/pictureHandling.py
View file @
fa31a565
...
@@ -4,6 +4,7 @@ import tensorflow as tf
...
@@ -4,6 +4,7 @@ import tensorflow as tf
from
src.enum.marktEnum
import
Markt
from
src.enum.marktEnum
import
Markt
# Wird nicht mehr gebraucht
def
createPathWithPictures
():
def
createPathWithPictures
():
# Pfad zu den 6 Ordnern
# Pfad zu den 6 Ordnern
main_folder_path
=
"/assets/Bilder/Datengrundlage"
main_folder_path
=
"/assets/Bilder/Datengrundlage"
...
@@ -26,7 +27,7 @@ def createPathWithPictures():
...
@@ -26,7 +27,7 @@ def createPathWithPictures():
shutil
.
copy
(
image_path
,
new_subfolder_path
)
shutil
.
copy
(
image_path
,
new_subfolder_path
)
def
generate
AugmentedNotOOSP
ictures
():
def
generate
_augmented_not_oos_p
ictures
():
for
markt
in
Markt
:
for
markt
in
Markt
:
# Pfad zum Ordner "!OOS"
# Pfad zum Ordner "!OOS"
folder_path
=
"assets/Bilder/Datengrundlage_Test/"
+
markt
.
name
+
"/"
folder_path
=
"assets/Bilder/Datengrundlage_Test/"
+
markt
.
name
+
"/"
...
@@ -62,8 +63,6 @@ def get_images():
...
@@ -62,8 +63,6 @@ def get_images():
brightness_range
=
[
0.5
,
1.5
],
brightness_range
=
[
0.5
,
1.5
],
zoom_range
=
0.5
,
zoom_range
=
0.5
,
)
)
# specify imagenet mean values for centering
# datagen.mean = [124, 150, 130]
return
augmentedImageDefinition
return
augmentedImageDefinition
...
...
src/knn/createKNN.py
View file @
fa31a565
...
@@ -3,7 +3,7 @@ from src.enum.marktEnum import Markt
...
@@ -3,7 +3,7 @@ from src.enum.marktEnum import Markt
def
fit_model
(
config
,
model
,
train_it
,
test_it
,
callback
):
def
fit_model
(
config
,
model
,
train_it
,
test_it
,
callback
):
trained_model
=
model
.
fit
(
model
.
fit
(
train_it
,
train_it
,
steps_per_epoch
=
len
(
train_it
),
steps_per_epoch
=
len
(
train_it
),
validation_data
=
test_it
,
validation_data
=
test_it
,
...
@@ -12,7 +12,6 @@ def fit_model(config, model, train_it, test_it, callback):
...
@@ -12,7 +12,6 @@ def fit_model(config, model, train_it, test_it, callback):
verbose
=
1
,
verbose
=
1
,
callbacks
=
[
callback
]
callbacks
=
[
callback
]
)
)
return
trained_model
def
evaluate_model
(
model
,
test_it
,
datagen
,
config
,
config_knn
):
def
evaluate_model
(
model
,
test_it
,
datagen
,
config
,
config_knn
):
...
...
src/knn/defineKNN.py
View file @
fa31a565
...
@@ -47,11 +47,9 @@ def get_next_layer(units, activation_function, flat_or_dense):
...
@@ -47,11 +47,9 @@ def get_next_layer(units, activation_function, flat_or_dense):
def
get_optimization_method
(
optimization_method
):
def
get_optimization_method
(
optimization_method
):
if
optimization_method
==
Optimierungsverfahren
.
SGD
:
if
optimization_method
==
Optimierungsverfahren
.
SGD
:
return
tf
.
keras
.
optimizers
.
SGD
(
learning_rate
=
0.001
,
momentum
=
0.9
)
return
tf
.
keras
.
optimizers
.
experimental
.
SGD
(
learning_rate
=
0.001
,
momentum
=
0.9
)
if
optimization_method
==
Optimierungsverfahren
.
Adam
:
if
optimization_method
==
Optimierungsverfahren
.
Adam
:
return
tf
.
keras
.
optimizers
.
Adam
()
return
tf
.
keras
.
optimizers
.
Adam
Adam
()
if
optimization_method
==
Optimierungsverfahren
.
Ftrl
:
if
optimization_method
==
Optimierungsverfahren
.
Ftrl
:
return
tf
.
keras
.
optimizers
.
legacy
.
Ftrl
(
learning_rate
=
0.001
,
return
tf
.
keras
.
optimizers
.
legacy
.
Ftrl
()
learning_rate_power
=-
0.5
,
initial_accumulator_value
=
0.1
)
return
None
return
None
src/result/analyseExcel.py
View file @
fa31a565
...
@@ -129,5 +129,5 @@ def write_matrix_in_excel(sheet, unique_opt, unique_act, final_matrix, c):
...
@@ -129,5 +129,5 @@ def write_matrix_in_excel(sheet, unique_opt, unique_act, final_matrix, c):
# Call the function with the folder path
# Call the function with the folder path
# swap_excel_cols("/Users/dwillers/Programmierung/Master/Okan-Server/Results Kopie/5050")
# swap_excel_cols("/Users/dwillers/Programmierung/Master/Okan-Server/Results Kopie/5050")
# swap_file_cols("/Users/dwillers/Programmierung/Master/Okan-Server/Results Kopie/5050/Ftrl_softmax_softmax_03_02_23__03_1
9.xlsx")
swap_file_cols
(
"/Users/dwillers/Programmierung/Master/Okan-Server/Results Kopie/1090/SGD_sigmoid_ReLU_24_01_23__08_3
9.xlsx"
)
# read_metrics("/Users/dwillers/Programmierung/Master/Okan-Server/Results Kopie/5050")
# read_metrics("/Users/dwillers/Programmierung/Master/Okan-Server/Results Kopie/5050")
src/result/createExcelFile.py
View file @
fa31a565
import
time
from
datetime
import
datetime
,
timedelta
from
datetime
import
datetime
import
openpyxl
import
openpyxl
...
@@ -30,7 +29,6 @@ def create_excel_result(worksheet, r, callback, config, config_knn, evaluate_met
...
@@ -30,7 +29,6 @@ def create_excel_result(worksheet, r, callback, config, config_knn, evaluate_met
r
=
r
+
2
r
=
r
+
2
# Schreiben Sie die Überschriften in die erste Zeile
# Schreiben Sie die Überschriften in die erste Zeile
# TODO: Ergänzung Recall 1, Recall 2
worksheet
.
cell
(
row
=
r
,
column
=
1
)
.
value
=
'epoch'
worksheet
.
cell
(
row
=
r
,
column
=
1
)
.
value
=
'epoch'
worksheet
.
cell
(
row
=
r
,
column
=
2
)
.
value
=
'training_loss'
worksheet
.
cell
(
row
=
r
,
column
=
2
)
.
value
=
'training_loss'
worksheet
.
cell
(
row
=
r
,
column
=
3
)
.
value
=
'training_accuracy'
worksheet
.
cell
(
row
=
r
,
column
=
3
)
.
value
=
'training_accuracy'
...
@@ -76,7 +74,7 @@ def create_excel_result(worksheet, r, callback, config, config_knn, evaluate_met
...
@@ -76,7 +74,7 @@ def create_excel_result(worksheet, r, callback, config, config_knn, evaluate_met
worksheet
.
cell
(
row
=
r
,
column
=
4
)
.
value
=
evaluate_metrics
[
3
]
worksheet
.
cell
(
row
=
r
,
column
=
4
)
.
value
=
evaluate_metrics
[
3
]
worksheet
.
cell
(
row
=
r
,
column
=
5
)
.
value
=
evaluate_metrics
[
2
]
worksheet
.
cell
(
row
=
r
,
column
=
5
)
.
value
=
evaluate_metrics
[
2
]
r
=
r
+
4
r
=
r
+
4
return
worksheet
,
r
return
r
# TODO: Abschluss Statistik nach Cross-Validation von einer Konfiguration: Durchschnitt Accuracy, Recall 1, Recall 2, Loss, Duration für Evaluation
# TODO: Abschluss Statistik nach Cross-Validation von einer Konfiguration: Durchschnitt Accuracy, Recall 1, Recall 2, Loss, Duration für Evaluation
...
@@ -120,11 +118,9 @@ def sum_values_into_one_array(model_evaluate_metrics, training_duration_models):
...
@@ -120,11 +118,9 @@ def sum_values_into_one_array(model_evaluate_metrics, training_duration_models):
avg_array
=
[
value
/
num_arrays
for
value
in
sum_array
]
avg_array
=
[
value
/
num_arrays
for
value
in
sum_array
]
# Jetzt durchschnittsdauer des Modelltrainings berechnen
# Jetzt durchschnittsdauer des Modelltrainings berechnen
current_time
=
datetime
.
now
()
add_times
=
timedelta
()
add_times
=
current_time
for
training_time
in
training_duration_models
:
for
training_time
in
training_duration_models
:
add_times
=
add_times
+
training_time
add_times
+=
training_time
add_times
=
add_times
-
current_time
# Durchschnitt berechnen
# Durchschnitt berechnen
average_duration
=
add_times
/
len
(
training_duration_models
)
average_duration
=
add_times
/
len
(
training_duration_models
)
# Ergebnis dem avg_array hinzufügen
# Ergebnis dem avg_array hinzufügen
...
...
Write
Preview
Markdown
is supported
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