palmettos / neat-autoencoders

Evolvable autoencoders for NEAT-Python
BSD 3-Clause "New" or "Revised" License
4 stars 2 forks source link

Number of hidden nodes is greater than 0 #1

Open SasoPavlic opened 2 years ago

SasoPavlic commented 2 years ago

Greeting developers,

When assigning in the configuration file (test-autoencoder-novelty.cfg) num_hidden > 0

config_file

the following error is displayed:

_Traceback (most recent call last): File "C:\Users\user1\PycharmProjects\autoencoders-neat\neat\genome.py", line 716, in configure_new node_key = config.get_new_nodekey(self.nodes) AttributeError: 'AutoencoderGenome' object has no attribute 'nodes'

When looking into code, we can clearly see that self.nodes is used, even though there is no declaration of it.

no_nodes

Am I missing something in a configuration file or this feature was not fully developed? I would like that autoencoders-neat would be able to build NNs with hidden layers as well.

palmettos commented 2 years ago

Hi @SasoPavlic -- sorry for this issue. This code is definitely a bit hacky and I probably never tested the case where num_hidden > 0. I haven't looked at this in a while, but I think what's passed into get_new_node_key needs to be a combination of the self.encoder.nodes and self.decoder.nodes dicts. See get_new_node_key for reference: https://github.com/palmettos/autoencoders-neat/blob/f2cc0ae8bd5cc33cc9b1444e610b82e978761141/neat/genome.py#L114-L122

The node keys are just ascending integers.

If you feel up to fixing this, I'd be happy to accept a pull request for it. Otherwise, I'll try to get around to it soon.

Out of curiosity, what are you using the code for? I honestly didn't expect anyone to be interested in it. 😅

SasoPavlic commented 2 years ago

Hi @palmettos. To begin, I'd want to express my admiration for your implementation. Designing autoencoders topology using NEAT in such an elegant manner.

I'm also surprised that you responded so quickly 😅. Thank you for your feedback, it gave me an idea of what I need to implement. Yes, I will try to fix the bug and trigger the pull request once I am done (perhaps by the end of this week).

To address your question, I believe this is the power of open-source programming 😄. I got recently (this year) interested in algorithms capable of designing NNs by using nature-inspired techniques (evolution, swarm intelligence, ...). If you don't mind I would like to ask you for a personal/work contact, where I can describe to you what I want to achieve with your code (no further action needed from your side, just my proposal to let know the author of the code).

My e-mail: saso.pavlic@student.um.si

palmettos commented 2 years ago

Thanks! I tried to make the interface as simple as possible. Ideally I would like to decouple this from neat-python entirely and let it be just an extension where I only import neat-python. Unfortunately the author no longer maintains the original library and implementing this required some modifications to the library itself (at least on my first pass -- it might be possible to avoid doing that, but I think it would be more work). I sent you an email, feel free to reach out. I like talking about this stuff.