Skip to content

Remove dangling nodes #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 11 commits into
base: gitlab-runner
Choose a base branch
from
Open

Conversation

markste-in
Copy link
Owner

Removes dangling nodes

solves CodeReclaimers#250

@markste-in markste-in changed the base branch from master to gitlab-runner August 13, 2023 04:55
@allinduetime
Copy link

Removes dangling nodes

solves CodeReclaimers#250

Hey mark I’m getting an error on this, says the trim config item is unknown. I’m importing base neat, I have it in the [NEAT] Section. Does it belong somewhere else?

@allinduetime
Copy link

allinduetime commented Jun 8, 2024

Removes dangling nodes
solves CodeReclaimers#250

Hey mark I’m getting an error on this, says the trim config item is unknown. I’m importing base neat, I have it in the [NEAT] Section. Does it belong somewhere else?

Figured it out, the configuration name isn’t listed in reproduction.py
Edit: That in fact did not fix it
Edit 2: it did fix it I was just not in the actual python library for the imports

@allinduetime
Copy link

Ok back on last bit, AttributeError: 'DefaultGenome' object has no attribute 'trim_network'
more fully:
Traceback (most recent call last):
File "filename", line 43, in
winner = p.run(eval_genomes,1000)
^^^^^^^^^^^^^^^^^^^^^^^^
File "\site-packages\neat\population.py", line 110, in run
self.population = self.reproduction.reproduce(self.config, self.species,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "\site-packages\neat\reproduction.py", line 104, in reproduce
member.trim_network(config.genome_config)
^^^^^^^^^^^^^^^^^^^
AttributeError: 'DefaultGenome' object has no attribute 'trim_network'

yeeted half the file names to keep my stuff safe but yeah thats a lil funky

@markste-in
Copy link
Owner Author

markste-in commented Jun 8, 2024

Did you install the correct version of NEAT?
"trim_network" is a function i implemented to trim dangling nodes.

You can do it the following way (I would recommend to use a separate virtual environment)

git clone https://github.com/markste-in/neat-python.git
cd neat-python
pip install -e .

the "-e ." installs the module from the current folder as "editable project". That means you can import neat normally without local references but still make local changes to the file in the project and see the changes in the module immediately.

If you did it correctly you should see the "trim_function" in the neat-python/neat/genome.py in line 302

if you just do pip install neat it will pull neat from pypi without the changes.

@allinduetime
Copy link

Yep turns out most of my problems came from that. Though I do recommend a couple of quick fixes in your code. Just a sec

@allinduetime
Copy link

if self.reproduction_config.trim_dangling_after_n_generations_wo_improvment >= 0: for specie in species.species.values(): if generation - specie.last_improved > self.reproduction_config.trim_dangling_after_n_generations_wo_improvment: for member in specie.members.values(): member.trim_network(config.genome_config)
And at line 28, add in ConfigParameter('trim_dangling_after_n_generations_wo_improvment',int)

@markste-in
Copy link
Owner Author

yeah u r right. it makes more sense that way. Gonna change it and test it and then push it

@allinduetime
Copy link

Yeah, it yelled at me when that wasn’t there so I had to put it in manually

@markste-in
Copy link
Owner Author

Yeah, it yelled at me when that wasn’t there so I had to put it in manually

Depending where you add ConfigParameter('trim_dangling_after_n_generations_wo_improvment',int) you have to add trim_dangling_after_n_generations_wo_improvment at different places in the config file. Before you had to add it to the "NEAT" area. Now I changed it to the reproduction area

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy