Reputation: 1
I was creating a simple game AI using NEAT. However, I discovered an issue where the game window would just open and close as it transitioned from generation 0 to generation 1, and in reality, it kept repeating generation 0, so I asked gpt to modify it. When I ran the modified code, I got the following message:
eunwoocho@Eunwoos-MacBook-Pro python % /usr/local/bin/python3 "/Users/eunwoocho/Documents/Python/import pygame.py"
pygame 2.5.2 (SDL 2.28.3, Python 3.12.2)
Hello from the pygame community. https://www.pygame.org/contribute.html
****** Running generation 0 ******
Population's average fitness: 4.55500 stdev: 8.71705
Best fitness: 68.00000 - size: (10, 36) - species 69 - id 69
Average adjusted fitness: 0.067
Mean genetic distance 3.545, standard deviation 0.244
Population of 402 members in 200 species:
ID age size fitness adj fit stag
==== === ==== ======= ======= ====
1 0 2 1.0 0.015 0
.....omit....
200 0 2 0.0 0.000 0
Total extinctions: 0
Generation time: 2.484 sec
****** Running generation 1 ******
Traceback (most recent call last):
File "/Users/eunwoocho/Documents/Python/import pygame.py", line 129, in <module>
run(config_path, 50)
File "/Users/eunwoocho/Documents/Python/import pygame.py", line 121, in run
winner = p.run(lambda genomes, config: main(genomes, config, p.generation, target_generations), target_generations)
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/neat/population.py", line 89, in run
fitness_function(list(iteritems(self.population)), self.config)
File "/Users/eunwoocho/Documents/Python/import pygame.py", line 121, in <lambda>
winner = p.run(lambda genomes, config: main(genomes, config, p.generation, target_generations), target_generations)
File "/Users/eunwoocho/Documents/Python/import pygame.py", line 57, in main
net = neat.nn.FeedForwardNetwork.create(g, config)
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/neat/nn/feed_forward.py", line 51, in create
activation_function = config.genome_config.activation_defs.get(ng.activation)
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/neat/activations.py", line 128, in get
raise InvalidActivationFunction("No such activation function: {0!r}".format(name))
neat.activations.InvalidActivationFunction: No such activation function: 'sum'
The game did move from generation 0 to generation 1, but an error message
"No such activation function: 'sum'"
occurred. However, I have never used 'sum' in config-feedfoword or in the game code, so I'm wondering why this error is occurring.
And this is the code modified by GPT and config-feedforward.txt file:
https://drive.google.com/drive/folders/1zgzum4HR72b0eOUtvjY7tlB3v8xk0_O5?usp=drive_link
To solve the problem, I checked for any code containing sum, and following GPT's advice that the activation_default item was the issue, I changed it from activation_default = relu to sigmoid, but the 'sum' error still appears. The truly frustrating part is that I haven't used the word sum at all. Please help this suffering young developer.
Upvotes: 0
Views: 65
Reputation: 1
Instead of sum you can use sigmoid, relu or something different and brute force your way into it, kindly check the official documentation of NEAT
Upvotes: 0