'How to use keras model.reset_state in function?
Hi I have a question the way to reset model in for loop.
To do a grid search to find the optimal model for the dataset, I made for loop with parameters.
Here's the structure of the model.
list_loss = []
# Define model
def Model():
model = Sequential()
model.add(Dense(~~~~))
model.add(Dense(1, activation = 'sigmoid')
model.compile(optimizer = 'adam', loss = ~~)
return model
model = Model()
for epoch in epochs_:
for batch in batchs_:
# train model
hist = model.fit(X_train, y_train)
# save the loss
list_loss.append(hist.history['loss'][-1])
print('layers: {}, batch size: {}, epoch: {}, and loss: {}'.format(a, batch_size_, epochs_, hist.history['loss'][-1])
And here's the result. it looks like the previous loss give impact to the next one. How should I reset on each epoch?
Thank you in advance.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|

