Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

ga_instance.save will not work with tqdm example #262

Open
Labels
bugSomething isn't working
@mrh335

Description

I am running the example on how to use TQDM. I have used this successfully in a prior version and installation, but when running my previous code or the example code, I receive the error:
File C:\ProgramData\Anaconda3\envs\pygad_2_2_0-2\Lib\site-packages\cloudpickle\cloudpickle.py:1245 in dump
return super().dump(obj)

TypeError: cannot pickle '_hashlib.HMAC' object

Pygad version 3.1.0 and also tried 3.2.0

This is the code that was run returning this result.

import pygad
import numpy
import tqdm
equation_inputs = [4,-2,3.5]
desired_output = 44
def fitness_func(ga_instance, solution, solution_idx):
 output = numpy.sum(solution * equation_inputs)
 fitness = 1.0 / (numpy.abs(output - desired_output) + 0.000001)
 return fitness
def on_generation_progress(ga):
 pbar.update(1)
num_generations = 100
with tqdm.tqdm(total=num_generations) as pbar:
 ga_instance = pygad.GA(num_generations=num_generations,
 sol_per_pop=5,
 num_parents_mating=2,
 num_genes=len(equation_inputs),
 fitness_func=fitness_func,
 on_generation=on_generation_progress)
 ga_instance.run()
ga_instance.plot_result()
ga_instance.save("test")

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

        AltStyle によって変換されたページ (->オリジナル) /