For my regression , these are the results of the best model that I obtained using keras-tuner
.
best_model.summary()
Model: "sequential"
_________________________________________________________________
Layer (type) Output Shape Param #
=================================================================
dense (Dense) (None, 1024) 64512
_________________________________________________________________
dropout (Dropout) (None, 1024) 0
_________________________________________________________________
dense_1 (Dense) (None, 32) 32800
_________________________________________________________________
dense_2 (Dense) (None, 1) 33
=================================================================
Total params: 97,345
Trainable params: 97,345
Non-trainable params: 0
_________________________________________________________________
I am tuning for three hyperparameters: neurons in 1st layer, neurons in 2nd layer and learning rate. I repeated this a few times and observed the number of neurons mostly remain the same. Following this, I decided to avoid tuning to save time, and instead manually define the model as follows:
model = Sequential()
model.add(Dense(1024, activation='relu'))
model.add(Dropout(0.3))
model.add(Dense(32, activation='relu'))
model.add(Dense(1, activation=None))
## Compiling the model
model.compile(loss='mean_squared_error',
optimizer=tf.keras.optimizers.Adagrad(learning_rate=0.001),
metrics=[tf.keras.metrics.RootMeanSquaredError()])
filepath = "./dump/vol.weights.best.hdf" + str(i)
checkpoint = ModelCheckpoint(filepath,
monitor='val_root_mean_squared_error',
verbose=1,
save_best_only=True,
save_weights_only=True,
mode='min')
callbacks_list = [checkpoint]
history = model.fit(x_train,
y_train,
epochs=50,
batch_size=1,
validation_data=(x_val, y_val),
callbacks=callbacks_list,
verbose=0)
model.load_weights(filepath)
y_pred = model.predict(x_test)
I have 30 splits of my dataset and I apply the model 30 times and save the weights in separate files in each iteration. The number of epochs is low now as I am just testing.
My results are very low compared to the results obtained when I apply the 'best' model obtained with keras-tuner
. In fact, I don't even reload the libraries. The data splits are exactly the same. Everything is exactly the same! There is absolutely no difference except that I manually define the model but with the same parameters as returned by the tuner. Is there something wrong that I am doing?
Hope the question is clear. I can clear any doubts if needed.