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
Bannier Delphine
Projet_FR
Commits
009f122c
Commit
009f122c
authored
May 18, 2021
by
Bannier Delphine
Browse files
add model
parent
85e62c1d
Changes
1
Hide whitespace changes
Inline
Side-by-side
processing/models.py
View file @
009f122c
...
...
@@ -9,6 +9,7 @@ from tensorflow.keras.layers import Dense
from
tensorflow.keras.layers
import
Flatten
from
tensorflow.keras.layers
import
Input
from
tensorflow.keras.layers
import
concatenate
from
tensorflow.keras.layers
import
GaussianNoise
...
...
@@ -61,6 +62,17 @@ def create_mlp(dim, regress=True):
# return our model
return
model
def
create_mlp2
(
dim
,
regress
=
True
):
model
=
Sequential
()
model
.
add
(
GaussianNoise
(
0.2
,
input_shape
=
(
dim
,)))
model
.
add
(
Dense
(
8
,
activation
=
"relu"
))
model
.
add
(
Dense
(
4
,
activation
=
"relu"
))
# add dense for regression
model
.
add
(
Dense
(
1
))
return
model
def
create_hybrid
(
nb_attributes
,
shape
=
(
240
,
240
,
1
)):
# create cnn and mlp models
mlp
=
create_mlp
(
nb_attributes
)
...
...
@@ -69,4 +81,14 @@ def create_hybrid(nb_attributes,shape=(240,240,1)):
x
=
Dense
(
4
,
activation
=
"relu"
)(
combinedInput
)
x
=
Dense
(
1
,
activation
=
"linear"
)(
x
)
model
=
Model
(
inputs
=
[
mlp
.
input
,
cnn
.
input
],
outputs
=
x
)
return
model
def
create_hybrid2
(
nb_attributes
,
shape
=
(
240
,
240
,
1
)):
# create cnn and mlp models
mlp
=
create_mlp2
(
nb_attributes
)
cnn
=
create_cnn
(
*
shape
)
combinedInput
=
concatenate
([
mlp
.
output
,
cnn
.
output
])
x
=
Dense
(
4
,
activation
=
"relu"
)(
combinedInput
)
x
=
Dense
(
1
,
activation
=
"linear"
)(
x
)
model
=
Model
(
inputs
=
[
mlp
.
input
,
cnn
.
input
],
outputs
=
x
)
return
model
\ No newline at end of file
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