Movatterモバイル変換


[0]ホーム

URL:


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

Save PyGAD output#184

Unanswered
zsbeheshti asked this question inQ&A
Apr 25, 2023· 1 comments· 3 replies
Discussion options

Dear all,

I am using PyGAD and I want to save its outputs. How can I do this?

Regards

You must be logged in to vote

Replies: 1 comment 3 replies

Comment options

Hi@zsbeheshti,

You can use thesave() method to save the instance and then use theload() function to load it back.

This is an example.

importpygadimportnumpyfunction_inputs= [4,-2,3.5,5,-11,-4.7]desired_output=44deffitness_func(ga_instance,solution,solution_idx):output=numpy.sum(solution*function_inputs)fitness=1.0/ (numpy.abs(output-desired_output)+0.000001)returnfitnessga_instance=pygad.GA(num_generations=10,num_parents_mating=10,sol_per_pop=20,num_genes=len(function_inputs),fitness_func=fitness_func,suppress_warnings=True)ga_instance.run()# Saving the GA instance.filename='genetic'ga_instance.save(filename=filename)# Loading the saved GA instance.loaded_ga_instance=pygad.load(filename=filename)loaded_ga_instance.plot_fitness()
You must be logged in to vote
3 replies
@zsbeheshti
Comment options

Is there another way to save the output so that the saved output can be received and checked in the format of numbers, graphs, etc.?

@ahmedfgad
Comment options

Not yet supported.

@zsbeheshti
Comment options

Thank you.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Category
Q&A
Labels
questionFurther information is requested
2 participants
@zsbeheshti@ahmedfgad

[8]ページ先頭

©2009-2025 Movatter.jp