Replies: 8 comments 7 replies
-
This line looks problematic: genome_key = genome_key.astype(jnp.uint64) A key is a pair of I can't check whether this is the case because I'm unable to run your code without access to your config file. If you want further help, I'd suggest putting together a minimal reproducible example so that others can reproduce the behavior you're seeing. |
Beta Was this translation helpful? Give feedback.
-
The line ' genome_key = genome_key.astype(jnp.uint64)' was llm suggestion and it makes no difference whether it is there or not, still the same error. My config file is attached. I also tried ' genome_key = jrandom.PRNGKey(genome_id) ' |
Beta Was this translation helpful? Give feedback.
-
This is the entire code I am running on single cell on a notebook and the config.txt is the only variable from outside the code, I run nothing before running this cell. I cleared the kernel and just ran this cell again import jax
import neat
import jax.random as random
from evojax.task.slimevolley import SlimeVolley
import time
#jax.config.update("jax_enable_x64", True)
def fitness_fn(genomes, config):
# Generate a new PRNG key for each fitness evaluation
# This ensures that each genome gets a unique PRNG key
prng_key = random.PRNGKey(int(time.time()))
for genome_id, genome in genomes:
try:
net = neat.nn.FeedForwardNetwork.create(genome, config)
env = SlimeVolley(test=False)
# Split the PRNG key to get a unique key for this genome
#prng_key, genome_key = random.split(prng_key)
prng_key, genome_key = random.split(prng_key, 2)
#genome_key = genome_key.astype(jnp.uint64)
print('genome_key:', genome_key)
state = env.reset(genome_key)
print(f"State after reset: {state}")
total_reward = 0
while not state.done:
action = net.activate(state.obs)
state, reward, done = env.step(action)
total_reward += reward
genome.fitness = total_reward
except Exception as e:
print(f"Error occurred while evaluating genome {genome_id}: {e}")
genome.fitness = 0
config = neat.Config(neat.DefaultGenome, neat.DefaultReproduction,
neat.DefaultSpeciesSet, neat.DefaultStagnation,
r'C:\Users\kehsa\Sakana\project1\evojax\config.txt')
p = neat.Population(config)
p.run(fitness_fn, 50) and got these errors: |
Beta Was this translation helpful? Give feedback.
-
I put the config value in a cell as such : and tried this format Merge dictionariesmerged_config = {**config_dict["NEAT"], **config_dict["DefaultGenome"], **config_dict["DefaultReproduction"], **config_dict["DefaultSpeciesSet"], **config_dict["DefaultStagnation"]} Create NEAT configneat_config = neat.Config(neat.DefaultGenome, neat.DefaultReproduction, neat.DefaultSpeciesSet, neat.DefaultStagnation, **merged_config) p = neat.Population(neat_config) but getting this error: difficulty feeding config.txt to neat.config() !! |
Beta Was this translation helpful? Give feedback.
-
It is an assignment that I have to use neat. I installed neat from neat-python wheel I believe https://pypi.org/project/neat-python/#files under download files. It is uploaded 2017. "pip install neat-python" may also work. I tried to recreate the config.txt file on a cell and pass it as dictionary to neat_config as such /// def fitness_fn(genomes, config):
Merge dictionaries#merged_config = {**config_dict["[NEAT]"], **config_dict["[DefaultGenome]"], **config_dict["[DefaultReproduction]"], **config_dict["[DefaultSpeciesSet]"], **config_dict["[DefaultStagnation]"]} merged_config = "" #print(merged_config) Create NEAT configneat_config = neat.Config(neat.DefaultGenome, neat.DefaultReproduction, neat.DefaultSpeciesSet, neat.DefaultStagnation, merged_config) p = neat.Population(neat_config) The code dictionary has the exact format of the config.txt but the neat.config is still looking for a local file and does not seem to accept other formats, as I get this error, I am not sure if there is a way around it. Cell In[3], line 55 File ~\miniconda3\envs\sakana\lib\site-packages\neat\config.py:153, in Config.init(self, genome_type, reproduction_type, species_set_type, stagnation_type, filename) Exception: No such config file: C:\Users\kehsa\sakana\project1\evojax[NEAT] |
Beta Was this translation helpful? Give feedback.
-
I printed my genome_key after split and seems to be the right type |
Beta Was this translation helpful? Give feedback.
-
@jakevdp, I guess you have no extra ideas of how I can figure this syntax error ///Error occurred while evaluating genome 1: JAX encountered invalid PRNG key data: expected key_data.ndim >= 1; got ndim=0 ///. Thanks anyways. |
Beta Was this translation helpful? Give feedback.
-
@jakevdp I am not sure exactly how the minimal reproduction from your point of view is. If you have installed neat-python and other related import libraries from the code given and have config.txt file also downloaded you should be able to reproduce the error. If I am wrong please let me know at which point. The github pages I am following to reproduce slimevolley using neat algorithm and JAX are: https://github.com/google/evojax |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I have this code for creating PRNGkey:
I get this output:
It breaks on: state=env.reset(genome_key)
I don't fully understand what the error is and trying different methods to reshape did not work. My Jax version is 0.4.26
Beta Was this translation helpful? Give feedback.
All reactions