How do I proceed to load a ga_instance as ".pkl" format in PyGad?
I have been trying to load the PyGad trained instance in another file, in order to make some prediction. But I have been having some problems in the loading process.
After the training phase, I saved the instance like this:
The saving function:
filename = 'GNN_CPTNet' #GNN_CPTNet.pkl
ga_instance.save(filename=filename)
The loading function:
loaded_ga_instance = pygad.load(filename=filename)
loaded_ga_instance.plot_result()
But, when I tried to load the instance in a new notebook or script, I could not load the instance, especially the &quot;GNN_CPT Net.pkl&quot; file.

In the new script, you should define the the fitness function and all the callback functions you used in the original script.
For example, if you used only the on_generation (callback_generation) parameter, then the following functions should be defined:
def fitness_func(solution, solution_idx):
    ...


def callback_generation(ga_instance):
    ...


This way, the saved instance will be loaded correctly.
Anyway, it is better to post the sample codes you used to give more accurate answer.
Thanks for using PyGAD :)
