Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Antoine PIGEAU
2015-Hubble-UserProfiles
Commits
a4824f9e
Commit
a4824f9e
authored
Dec 06, 2021
by
Antoine PIGEAU
Browse files
NN is done
parent
a8747aed
Changes
3
Hide whitespace changes
Inline
Side-by-side
source/classifierManager/model/denseNN.py
View file @
a4824f9e
...
...
@@ -29,7 +29,7 @@ import keras as kr
# from keras.utils import plot_model
from
keras.utils.vis_utils
import
plot_model
from
tensorflow.
keras
import
optimizers
from
keras
import
optimizers
from
classifierManager.model.neuralNetworkInitializer
import
ModelLSTM
from
classifierManager.model.neuralNetworkInitializer
import
ModelPerceptron
...
...
@@ -58,7 +58,7 @@ class DenseNN:
self
.
callbacks_list
=
[
kr
.
callbacks
.
EarlyStopping
(
monitor
=
'
acc
'
,
monitor
=
'
val_accuracy
'
,
patience
=
1
,
),
kr
.
callbacks
.
ModelCheckpoint
(
...
...
@@ -129,14 +129,15 @@ class DenseNN:
def
compile
(
self
):
#optimizer = 'rmsprop' #'adam'
optimizer
=
optimizers
.
RMSprop
(
lr
=
0.001
,
rho
=
0.9
,
epsilon
=
None
,
decay
=
0.0
)
#optimizer = optimizers.RMSprop(lr=0.001, rho=0.9, epsilon=None, decay=0.0)
optimizer
=
optimizers
.
RMSprop
(
lr
=
0.001
)
self
.
model
.
compile
(
optimizer
=
optimizer
,
loss
=
self
.
loss
,
metrics
=
[
'accuracy'
])
print
(
"DenseNN - compile() - compile is done"
)
def
fit
(
self
,
train_x
,
train_y
,
validation_x
,
validation_y
,
batchSize
=
32
,
epochs
=
20
):
print
(
"DenseNN - fit() - start fitting"
)
if
validation_x
is
None
and
validation_y
is
None
:
self
.
model
.
fit
(
x
=
train_x
,
...
...
@@ -146,7 +147,7 @@ class DenseNN:
verbose
=
2
)
else
:
self
.
model
.
fit
(
x
=
train_x
,
y
=
train_y
,
batch_size
=
batchSize
,
...
...
source/classifierManager/script/scriptNeuralNetwork.py
View file @
a4824f9e
...
...
@@ -256,7 +256,7 @@ class ScriptNeuralNetwork(ScriptClassifier):
for
_
in
range
(
0
,
ntime
):
#(accuracy, confusionMatrix, nbEpoch, auc)
result
=
self
.
predictionTask
(
course
,
whereToCut
,
cache
=
cache
)
result
=
self
.
predictionTask
(
course
,
whereToCut
)
if
auc
is
None
:
raise
ValueError
(
"classifierManager.script.ScriptNeuralNetwork - predictionTaskNTimes : auc is None"
)
...
...
@@ -310,6 +310,8 @@ class ScriptNeuralNetwork(ScriptClassifier):
accuracies
=
[]
aucs
=
[]
epochs
=
[]
size
=
len
(
self
.
classifier
.
nameGroups
)
avgConfusionMatrix
=
np
.
zeros
((
size
,
size
))
accuraciesPerClass
=
[]
dictAllCourses
=
{}
...
...
@@ -349,7 +351,7 @@ class ScriptNeuralNetwork(ScriptClassifier):
fileResult
.
write
(
str
(
auc
))
fileResult
.
write
(
"
\n
nbEpoch
\n
"
)
fileResult
.
write
(
str
(
nbE
poch
))
fileResult
.
write
(
str
(
e
poch
))
...
...
source/main/ocr/classificationExperiment.py
View file @
a4824f9e
...
...
@@ -109,7 +109,7 @@ if __name__ == "__main__":
''' for all periods '''
classifier
.
predictionTaskForAllPeriods
(
ntime
=
10
,
cache
=
Fals
e
)
classifier
.
predictionTaskForAllPeriods
(
ntime
=
10
,
cache
=
Tru
e
)
''' NN : all courses with hidden layers'''
...
...
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