Views
No views yet
1import tensorflow as tf
2from tensorflow.keras.models import load_model
3import numpy as np
4
5# Load the model
6model_path = 'path/to/save/directory/best_model_iphim.keras'
7model = load_model(model_path)
8
9# Compile the model if you want to continue training
10model.compile(optimizer='adam', loss='binary_crossentropy', metrics=['binary_accuracy'])
11
12# Example function to continue training
13def continue_training(model, new_train_ds, new_test_ds, epochs=10):
14 history = model.fit(new_train_ds, epochs=epochs, validation_data=new_test_ds)
15 return history
16
17# Example function to make predictions
18def make_predictions(model, input_data):
19 predictions = model.predict(input_data)
20 return predictions
21
22# Example usage
23if __name__ == "__main__":
24 # Load your new dataset here
25 new_train_ds = ... # Replace with your new training dataset
26 new_test_ds = ... # Replace with your new testing dataset
27
28 # Continue training
29 history = continue_training(model, new_train_ds, new_test_ds, epochs=10)
30
31 # Load new input data for predictions
32 new_input_data = ... # Replace with your new input data for predictions
33
34 # Make predictions
35 predictions = make_predictions(model, new_input_data)
36 print(predictions)
37