From 44cc0f865a1a77414dc08fe96bda2afb9bfe3bc4 Mon Sep 17 00:00:00 2001
From: artzai <artzai.picon@tecnalia.com>
Date: Fri, 30 Aug 2019 13:21:14 +0200
Subject: [PATCH] first final version

---
 house_prices_estimation_example_image.py          |  2 +-
 house_prices_estimation_example_image_and_data.py | 13 +++++++------
 2 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/house_prices_estimation_example_image.py b/house_prices_estimation_example_image.py
index 24fa709..46c76ea 100644
--- a/house_prices_estimation_example_image.py
+++ b/house_prices_estimation_example_image.py
@@ -43,7 +43,7 @@ def generate_simple_cnn_regression_model(input_shape,n_blocks=2,weights='',is_re
         model.load_weights(weights,by_name=True)
 
     if freeze:
-        for layer in model.layers[:-1]:
+        for layer in model.layers[:-2]:
             layer.trainable = False
 
     return model
diff --git a/house_prices_estimation_example_image_and_data.py b/house_prices_estimation_example_image_and_data.py
index 98b6da5..7760c2e 100644
--- a/house_prices_estimation_example_image_and_data.py
+++ b/house_prices_estimation_example_image_and_data.py
@@ -39,7 +39,7 @@ if __name__ == "__main__":
 
 
     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=False)
+    model_img = generate_simple_cnn_regression_model(input_shape_img, weights='regression_model_image_pretrained.h5',remove_head=True)
     input_data = [Input(input_shape_data),Input((input_shape_img,input_shape_img,3))]
 
     # y_data = model_data.layers[-2]#(input_data[0])
@@ -48,18 +48,19 @@ if __name__ == "__main__":
     y_img = model_img(input_data[1])
 
     y = Concatenate()([y_data, y_img])
+    y = Dense(32, activation='relu')(y)
     y = Dense(1,activation='sigmoid')(y)
 
-    for layer in model_img.layers:
-        layer.trainable = False
+    # for layer in model_img.layers:
+    #     layer.trainable = False
     model = Model(input_data,y)
 
 
-    opt = Adam(lr=1e-3, decay=1e-3 / 200)
-    model.compile(loss='mean_squared_error',
+    opt = Adam(lr=1e-3, decay=1e-3/400)
+    model.compile(loss='mean_absolute_error',
                   metrics=['mean_absolute_percentage_error', 'mean_absolute_error', 'mean_squared_error'],
                   optimizer=opt)
     model.summary()
-    model = train_model(trainX, trainY, testX, testY, model, show_plot=True, epochs=500, batch_size=32)
+    model = train_model(trainX, trainY, testX, testY, model, show_plot=True, epochs=400, batch_size=32)
     evaluate_regression_model(model, testX, testY, normalizer, show_plot=True)
     model.save('regression_model_combined.h5')
-- 
GitLab