diff --git a/house_prices_estimation_example_image.py b/house_prices_estimation_example_image.py index 24fa7098833b48ecfe12948f0f96d40bd7d94b71..46c76ea44e22baf2385bba3fb07943f5bfd1b3ce 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 98b6da53a10aa37be3517ea1d22014b8a2c5eb25..7760c2ef94cb6dea4d0cbe016d9a36850c5ba9eb 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')