@@ -16,8 +16,8 @@ def fitness_func(ga_instanse, solution, sol_idx):
1616 return solution_fitness
1717
1818def on_generation (ga_instance ):
19- print ("Generation = {generation}" . format ( generation = ga_instance .generations_completed ) )
20- print ("Fitness = {fitness}" . format ( fitness = ga_instance .best_solution ()[1 ]) )
19+ print (f "Generation = { ga_instance .generations_completed } " )
20+ print (f "Fitness = { ga_instance .best_solution ()[1 ]} " )
2121
2222# Build the keras model using the functional API.
2323input_layer = tensorflow .keras .layers .Input (360 )
@@ -57,8 +57,8 @@ def on_generation(ga_instance):
5757
5858# Returning the details of the best solution.
5959solution , solution_fitness , solution_idx = ga_instance .best_solution ()
60- print ("Fitness value of the best solution = {solution_fitness}" . format ( solution_fitness = solution_fitness ) )
61- print ("Index of the best solution : {solution_idx}" . format ( solution_idx = solution_idx ) )
60+ print (f "Fitness value of the best solution = { solution_fitness } " )
61+ print (f "Index of the best solution : { solution_idx } " )
6262
6363# Fetch the parameters of the best solution.
6464predictions = pygad .kerasga .predict (model = model ,
@@ -68,13 +68,13 @@ def on_generation(ga_instance):
6868
6969# Calculate the categorical crossentropy for the trained model.
7070cce = tensorflow .keras .losses .CategoricalCrossentropy ()
71- print ("Categorical Crossentropy : " , cce (data_outputs , predictions ).numpy ())
71+ print (f "Categorical Crossentropy : { cce (data_outputs , predictions ).numpy ()} " )
7272
7373# Calculate the classification accuracy for the trained model.
7474ca = tensorflow .keras .metrics .CategoricalAccuracy ()
7575ca .update_state (data_outputs , predictions )
7676accuracy = ca .result ().numpy ()
77- print ("Accuracy : " , accuracy )
77+ print (f "Accuracy : { accuracy } " )
7878
7979# model.compile(optimizer="Adam", loss="mse", metrics=["mae"])
8080
0 commit comments