Skip to content

pygad.load() tries to run the model #159

Open
@krkaufma

Description

@krkaufma

Hello and thank you for building PyGAD! It is an awesome module.

I am attempting to load a model checkpoint simply to export the plots.

The issue I am running into is the model appears to try and start running when I use pygad.load() on a model checkpoint (I set the number of generations arbitrarily high). Similarly, I found it odd that I had to have the callback and fitness function defined to be able to load the model.

The code:

import pygad
from main import callback_generation
from fitness import fitness_function

path = '../results/2023_01_31_15_05/model/genetic_2023_01_31_15_05_1744.pkl'

model = pygad.load(path)

model.plot_fitness()
model.plot_new_solution_rate()
model.plot_genes(plot_type='scatter')
model.plot_genes(graph_type='boxplot')

When I run pygad.load, the loaded genetic algorithm immediately creates a population and tries to run. Because I moved this model to another machine, this ultimately fails due to a missing file.

The error message (slightly redacted): 
FileNotFoundError: [Errno 2] No such file or directory: '../results/2023_02_06_14_42/...

It would be ideal if a user could load any model checkpoint to investigate it and the solutions without needing the callback and fitness functions or the model immediately attempting to run().

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions