uber-research / pytorch-neat Goto Github PK
View Code? Open in Web Editor NEWLicense: Apache License 2.0
License: Apache License 2.0
When running pip install -r requirements.txt, I got the error :
ERROR: No matching distribution found for torch==0.4.0 (from -r requirements.txt (line 5))
I'm doing some research in continual learning, and a HyperNEAT implementation would come in handy. I have tried many things, and for the life of me I cannot get this implementation to run.
When I use a modern version of torch, I get IndexError: tensors used as indices must be long, byte or bool tensors
after running the simple example.
I'm not sure if I can install pytorch 0.4.0, and even if I did I don't think this version supports CUDA.
Does anyone know if there is a way I can use this implementation, otherwise are there any other implementations of HyperNEAT I can use out there?
No matter how I attempt to start one of the examples (adaptive)
I get this error. Full log here.
File "g:/Emulators/ML AI open AI/env2.py", line 130, in <module>
run() # pylint: disable=no-value-for-parameter
File "C:\Users\Silver\AppData\Local\Programs\Python\Python37\lib\site-packages\click\core.py", line 764, in __call__
return self.main(*args, **kwargs)
File "C:\Users\Silver\AppData\Local\Programs\Python\Python37\lib\site-packages\click\core.py", line 717, in main
rv = self.invoke(ctx)
File "C:\Users\Silver\AppData\Local\Programs\Python\Python37\lib\site-packages\click\core.py", line 956, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "C:\Users\Silver\AppData\Local\Programs\Python\Python37\lib\site-packages\click\core.py", line 555, in invoke
return callback(*args, **kwargs)
File "g:/Emulators/ML AI open AI/env2.py", line 120, in run
winner = pop.run(eval_genomes, n_generations)
File "g:\emulators\ml ai open ai\src\neat-python\neat\population.py", line 88, in run
fitness_function(list(self.population.items()), self.config)
File "g:/Emulators/ML AI open AI/env2.py", line 110, in eval_genomes
raise e
File "g:/Emulators/ML AI open AI/env2.py", line 106, in eval_genomes
genome, config, debug=DEBUG and i % 100 == 0
File "C:\Users\Silver\AppData\Local\Programs\Python\Python37\lib\site-packages\tf_neat\multi_env_eval.py", line 30, in eval_genome
net = self.make_net(genome, config, self.batch_size)
File "g:/Emulators/ML AI open AI/env2.py", line 52, in make_net
device="gpu",
File "C:\Users\Silver\AppData\Local\Programs\Python\Python37\lib\site-packages\tf_neat\adaptive_linear_net.py", line 149, in create
output_activation=output_activation,
File "C:\Users\Silver\AppData\Local\Programs\Python\Python37\lib\site-packages\tf_neat\cppn.py", line 199, in create_cppn
assert len(leaf_names) == len(genome_config.input_keys)
AssertionError`
To add to this, I'm confused about the input coordinates and output coordinates. Is there no documentation on what this is supposed to mean? I thought possibly my NEAT config is conflicting with that but I'm seriously unsure of how to resolve it.
Is anyone aware of this issue with regards to the use of `device="cuda:0" when trying to run the CUDA version of the adaptive HyperNEAT example (T-Maze) I get the subject error.
Below a full Trace.
Has anyone encountered such a problem? seems to be originated after every generation ends as if the argument is of device=('cpu') instead of being CUDA.
Any help with this?
RuntimeError Traceback (most recent call last)
<ipython-input-2-621c87ec8634> in <module>
113
114 if __name__ == "__main__":
--> 115 run() # pylint: disable=no-value-for-parameter
<ipython-input-2-621c87ec8634> in run(n_generations, n_processes)
103 pop.add_reporter(logger)
104
--> 105 winner = pop.run(eval_genomes, n_generations)
106
107 print(f'Best Genome: {winner}')
/usr/local/lib/python3.7/dist-packages/neat/population.py in run(self, fitness_function, n)
87
88 # Evaluate all genomes using the user-provided function.
---> 89 fitness_function(list(iteritems(self.population)), self.config)
90
91 # Gather and report statistics.
<ipython-input-2-621c87ec8634> in eval_genomes(genomes, config)
93 print(genome)
94
---> 95 raise e
96
97 pop = neat.Population(config)
<ipython-input-2-621c87ec8634> in eval_genomes(genomes, config)
88 try:
89 genome.fitness = evaluator.eval_genome(
---> 90 genome, config, debug=DEBUG and i % 100 == 0
91 )
92 except Exception as e:
~/AHN_experiment_Tmaze/pytorch_neat/multi_env_eval.py in eval_genome(self, genome, config, debug)
43 net, states, debug=True, step_num=step_num)
44 else:
---> 45 actions = self.activate_net(net, states)
46 assert len(actions) == len(self.envs)
47 for i, (env, action, done) in enumerate(zip(self.envs, actions, dones)):
<ipython-input-2-621c87ec8634> in activate_net(net, states, debug, step_num)
41 print(net.delta_w_node)
42 print("W init: ", net.input_to_output[0])
---> 43 outputs = net.activate(states)#.to('cpu').numpy()
44 if debug and (step_num - 1) % 100 == 0:
45 print(f"\nStep: {step_num - 1}")
~/AHN_experiment_Tmaze/pytorch_neat/adaptive_linear_net.py in activate(self, inputs)
105 ).unsqueeze(2)
106
--> 107 outputs = self.activation(self.input_to_output.matmul(inputs))
108
109 input_activs = inputs.transpose(1, 2).expand(
RuntimeError: Expected object of device type cuda but got device type cpu for argument #1 'self' in call to _th_bmm
def dense_from_coo(shape, conns, dtype=torch.float64):
mat = torch.zeros(shape, dtype=dtype)
idxs, weights = conns
if len(idxs) == 0:
return mat
rows, cols = np.array(idxs).transpose()
mat[torch.LongTensor(rows), torch.LongTensor(cols)] = torch.tensor(
weights, dtype=dtype)
return mat
after changing torch.tensor to torch.longTensor. This error pops up.
Torch version 1.17
How to use image inputs, without flattening?
I am trying to run the examples.simple.main.py and I encounter the following exception:
RuntimeError: tensors used as indices must be long or byte tensors
I have the following packages installed with pip3 in python3.6:
neat-python==0.92
numpy==1.15.2+mkl
gym==0.10.5
click==6.7
torch==0.4.0
torchvision==0.2.1
This error occurs within pytorch_neat.recurrent_net in the dense_from_coo function:
def dense_from_coo(shape, conns, dtype=torch.float64):
mat = torch.zeros(shape, dtype=dtype)
idxs, weights = conns
if len(idxs) == 0:
return mat
rows, cols = np.array(idxs).transpose()
mat[torch.tensor(rows), torch.tensor(cols)] = torch.tensor(
weights, dtype=dtype)
return mat
The problem is that np.array is assuming int32 for the indexes, but torch wants int64.
Simple solution:
def dense_from_coo(shape, conns, dtype=torch.float64):
mat = torch.zeros(shape, dtype=dtype)
idxs, weights = conns
if len(idxs) == 0:
return mat
rows, cols = np.array(idxs, dtype=np.int64).transpose()
mat[torch.tensor(rows), torch.tensor(cols)] = torch.tensor(
weights, dtype=dtype)
return mat
The difference may be from the differing numpy versions, but I think this change makes sense regardless for torch tensor indexing.
Is there some means of performing backpropagation on the resultant neural network?
I tried to add this line, and there are problems with pickling it seems
pop.add_reporter(neat.Checkpointer(1))
Error:
Saving checkpoint to neat-checkpoint-0
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-53-0f6fae74326a> in <module>()
54
55 if __name__ == "__main__":
---> 56 run(100)
4 frames
<ipython-input-53-0f6fae74326a> in run(n_generations)
50 pop.add_reporter(neat.Checkpointer(1))
51
---> 52 pop.run(eval_genomes, n_generations)
53
54
/usr/local/lib/python3.6/dist-packages/neat/population.py in run(self, fitness_function, n)
127 self.species.speciate(self.config, self.population, self.generation)
128
--> 129 self.reporters.end_generation(self.config, self.population, self.species)
130
131 self.generation += 1
/usr/local/lib/python3.6/dist-packages/neat/reporting.py in end_generation(self, config, population, species_set)
34 def end_generation(self, config, population, species_set):
35 for r in self.reporters:
---> 36 r.end_generation(config, population, species_set)
37
38 def post_evaluate(self, config, population, species, best_genome):
/usr/local/lib/python3.6/dist-packages/neat/checkpoint.py in end_generation(self, config, population, species_set)
57
58 if checkpoint_due:
---> 59 self.save_checkpoint(config, population, species_set, self.current_generation)
60 self.last_generation_checkpoint = self.current_generation
61 self.last_time_checkpoint = time.time()
/usr/local/lib/python3.6/dist-packages/neat/checkpoint.py in save_checkpoint(self, config, population, species_set, generation)
68 with gzip.open(filename, 'w', compresslevel=5) as f:
69 data = (generation, config, population, species_set, random.getstate())
---> 70 pickle.dump(data, f, protocol=pickle.HIGHEST_PROTOCOL)
71
72 @staticmethod
TypeError: cannot serialize '_io.TextIOWrapper' object
Currently running the adaptive HyperNEAT example using device = "cuda:0"
Population size: 100
Elitism: 10%
No multiprocessing
It runs okay for several generations, up until the following exception is thrown from the cppn.py
Any help to sort out this issue is appreciated.
File "/pytorch_neat/cppn.py", line 108, in __call__
return self.get_activs(shape)
File "/pytorch_neat/cppn.py", line 93, in get_activs
self.activs = self.activate(xs, shape)
File "/pytorch_neat/cppn.py", line 87, in activate
raise Exception("Failed to activate node {}".format(self.name))
Exception: Failed to activate node delta_w
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.