Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
pilula_deep_learning
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
comvis_public
pilula_deep_learning
Commits
a48ab5b6
Commit
a48ab5b6
authored
5 years ago
by
Picon Ruiz, Artzai
Browse files
Options
Downloads
Patches
Plain Diff
another version
parent
44cc0f86
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
house_prices_estimation_example_image.py
+4
-4
4 additions, 4 deletions
house_prices_estimation_example_image.py
house_prices_estimation_example_image_and_data.py
+7
-6
7 additions, 6 deletions
house_prices_estimation_example_image_and_data.py
with
11 additions
and
10 deletions
house_prices_estimation_example_image.py
+
4
−
4
View file @
a48ab5b6
...
@@ -17,19 +17,19 @@ import matplotlib.pyplot as plt
...
@@ -17,19 +17,19 @@ import matplotlib.pyplot as plt
__author__
=
106360
__author__
=
106360
def
generate_simple_cnn_regression_model
(
input_shape
,
n_blocks
=
2
,
weights
=
''
,
is_regression
=
True
,
num_classes
=
1
,
freeze
=
False
,
remove_head
=
False
):
def
generate_simple_cnn_regression_model
(
input_shape
,
n_blocks
=
3
,
weights
=
''
,
is_regression
=
True
,
num_classes
=
1
,
freeze
=
False
,
remove_head
=
False
):
# define the model input
# define the model input
inputs
=
Input
(
shape
=
(
input_shape
,
input_shape
,
3
))
inputs
=
Input
(
shape
=
(
input_shape
,
input_shape
,
3
))
# loop over the number of filters
# loop over the number of filters
x
=
inputs
x
=
inputs
for
n
in
range
(
n_blocks
):
for
n
in
range
(
n_blocks
):
x
=
Conv2D
(
16
,
(
3
,
3
),
padding
=
"
same
"
,
name
=
'
conv_%d
'
%
n
)(
x
)
x
=
Conv2D
(
32
,
(
3
,
3
),
padding
=
"
same
"
,
name
=
'
conv_%d
'
%
n
)(
x
)
x
=
Activation
(
"
relu
"
)(
x
)
x
=
Activation
(
"
relu
"
)(
x
)
x
=
BatchNormalization
()(
x
)
#
x = BatchNormalization()(x)
x
=
MaxPooling2D
()(
x
)
x
=
MaxPooling2D
()(
x
)
x
=
Flatten
()(
x
)
x
=
Flatten
()(
x
)
x
=
Dense
(
6
,
activation
=
"
relu
"
,
name
=
'
pre_last_dense_reg
'
)(
x
)
x
=
Dense
(
1
6
,
activation
=
"
relu
"
,
name
=
'
pre_last_dense_reg
'
)(
x
)
if
not
remove_head
:
if
not
remove_head
:
if
is_regression
:
if
is_regression
:
y
=
Dense
(
num_classes
,
activation
=
"
sigmoid
"
,
name
=
'
last_dense_reg
'
)(
x
)
y
=
Dense
(
num_classes
,
activation
=
"
sigmoid
"
,
name
=
'
last_dense_reg
'
)(
x
)
...
...
This diff is collapsed.
Click to expand it.
house_prices_estimation_example_image_and_data.py
+
7
−
6
View file @
a48ab5b6
...
@@ -31,15 +31,15 @@ if __name__ == "__main__":
...
@@ -31,15 +31,15 @@ if __name__ == "__main__":
(
trainX_data
,
trainX_img
,
trainY
,
testX_data
,
testX_img
,
testY
),
normalizer
=
load_house_dataset_data
(
test_size
=
0.2
,
random_state
=
666
,
type
=
DatasetType
.
Both
)
(
trainX_data
,
trainX_img
,
trainY
,
testX_data
,
testX_img
,
testY
),
normalizer
=
load_house_dataset_data
(
test_size
=
0.2
,
random_state
=
666
,
type
=
DatasetType
.
Both
)
trainX
=
[
trainX_data
,
trainX_img
[
'
frontal
_img
'
]]
trainX
=
[
trainX_data
,
trainX_img
[
'
bathroom
_img
'
]]
testX
=
[
testX_data
,
testX_img
[
'
frontal
_img
'
]]
testX
=
[
testX_data
,
testX_img
[
'
bathroom
_img
'
]]
input_shape_data
=
trainX
[
0
].
shape
[
1
]
input_shape_data
=
trainX
[
0
].
shape
[
1
]
input_shape_img
=
trainX
[
1
].
shape
[
1
]
input_shape_img
=
trainX
[
1
].
shape
[
1
]
model_data
=
generate_simple_regression_model
(
input_shape_data
,
weights
=
'
regression_model_data.h5
'
,
remove_head
=
True
)
model_data
=
generate_simple_regression_model
(
input_shape_data
,
weights
=
'
regression_model_data.h5
'
,
remove_head
=
True
)
model_img
=
generate_simple_cnn_regression_model
(
input_shape_img
,
weights
=
'
regression_model_image_pretrained.h5
'
,
remove_head
=
Tru
e
)
model_img
=
generate_simple_cnn_regression_model
(
input_shape_img
,
weights
=
'
regression_model_image_pretrained.h5
'
,
remove_head
=
Fals
e
)
input_data
=
[
Input
(
input_shape_data
),
Input
((
input_shape_img
,
input_shape_img
,
3
))]
input_data
=
[
Input
(
input_shape_data
),
Input
((
input_shape_img
,
input_shape_img
,
3
))]
# y_data = model_data.layers[-2]#(input_data[0])
# y_data = model_data.layers[-2]#(input_data[0])
...
@@ -48,7 +48,8 @@ if __name__ == "__main__":
...
@@ -48,7 +48,8 @@ if __name__ == "__main__":
y_img
=
model_img
(
input_data
[
1
])
y_img
=
model_img
(
input_data
[
1
])
y
=
Concatenate
()([
y_data
,
y_img
])
y
=
Concatenate
()([
y_data
,
y_img
])
y
=
Dense
(
32
,
activation
=
'
relu
'
)(
y
)
y
=
BatchNormalization
()(
y
)
y
=
Dense
(
16
,
activation
=
'
relu
'
)(
y
)
y
=
Dense
(
1
,
activation
=
'
sigmoid
'
)(
y
)
y
=
Dense
(
1
,
activation
=
'
sigmoid
'
)(
y
)
# for layer in model_img.layers:
# for layer in model_img.layers:
...
@@ -56,11 +57,11 @@ if __name__ == "__main__":
...
@@ -56,11 +57,11 @@ if __name__ == "__main__":
model
=
Model
(
input_data
,
y
)
model
=
Model
(
input_data
,
y
)
opt
=
Adam
(
lr
=
1e-3
,
decay
=
1e-3
/
40
0
)
opt
=
Adam
(
lr
=
1e-3
,
decay
=
1e-3
/
25
0
)
model
.
compile
(
loss
=
'
mean_absolute_error
'
,
model
.
compile
(
loss
=
'
mean_absolute_error
'
,
metrics
=
[
'
mean_absolute_percentage_error
'
,
'
mean_absolute_error
'
,
'
mean_squared_error
'
],
metrics
=
[
'
mean_absolute_percentage_error
'
,
'
mean_absolute_error
'
,
'
mean_squared_error
'
],
optimizer
=
opt
)
optimizer
=
opt
)
model
.
summary
()
model
.
summary
()
model
=
train_model
(
trainX
,
trainY
,
testX
,
testY
,
model
,
show_plot
=
True
,
epochs
=
4
00
,
batch_size
=
32
)
model
=
train_model
(
trainX
,
trainY
,
testX
,
testY
,
model
,
show_plot
=
True
,
epochs
=
20
00
,
batch_size
=
32
)
evaluate_regression_model
(
model
,
testX
,
testY
,
normalizer
,
show_plot
=
True
)
evaluate_regression_model
(
model
,
testX
,
testY
,
normalizer
,
show_plot
=
True
)
model
.
save
(
'
regression_model_combined.h5
'
)
model
.
save
(
'
regression_model_combined.h5
'
)
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