Skip to content

Commit

Permalink
fix merge conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
bennr01 committed Dec 13, 2019
2 parents 4359e95 + c2b79c8 commit 2ed502b
Show file tree
Hide file tree
Showing 93 changed files with 534 additions and 500 deletions.
13 changes: 5 additions & 8 deletions .travis.yml
@@ -1,17 +1,14 @@
dist: precise
language: python
python:
- 2.7
- 3.4
- 3.5
- 3.6
- 3.3
- 3.4
- 3.5-dev
- 3.6-dev
- 3.7
- 3.7-dev
- 3.8
- 3.8-dev
- nightly
- pypy
- pypy3.5-5.8.0
- pypy3
install:
- pip install --upgrade nose coveralls coverage
- if [[ $TRAVIS_PYTHON_VERSION == 'pypy'* ]]; then export TRAVIS_WAIT=45; else export TRAVIS_WAIT=20; fi
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
@@ -1,5 +1,5 @@
Copyright (c) 2007-2011, cesar.gomes and mirrorballu2
Copyright (c) 2015-2017, CodeReclaimers, LLC
Copyright (c) 2015-2019, CodeReclaimers, LLC

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
following conditions are met:
Expand Down
36 changes: 30 additions & 6 deletions README.md
@@ -1,18 +1,42 @@
[![Build Status](https://travis-ci.org/CodeReclaimers/neat-python.svg)](https://travis-ci.org/CodeReclaimers/neat-python)
[![Coverage Status](https://coveralls.io/repos/CodeReclaimers/neat-python/badge.svg?branch=master&service=github)](https://coveralls.io/github/CodeReclaimers/neat-python?branch=master)

## STATUS NOTE ##

This project is currently in maintenance-only mode. I will make bug fixes, do cleanup, and possibly improve sample code
as I have time, but I will not be adding any new features. The forks by
[@drallensmith](https://github.com/drallensmith/neat-python) and [@bennr01](https://github.com/bennr01/neat-python) have
been extended beyond this implementation a great deal, so those might be better starting points if you need more
features than what you see here.

## About ##

NEAT (NeuroEvolution of Augmenting Topologies) is a method developed by Kenneth O. Stanley for evolving arbitrary neural
networks. This project is a Python implementation of NEAT. It was forked from the excellent project by @MattKallada,
and is in the process of being updated to provide more features and a (hopefully) simpler and documented API.
NEAT (NeuroEvolution of Augmenting Topologies) is a method developed by Kenneth O. Stanley for evolving arbitrary neural
networks. This project is a pure-Python implementation of NEAT with no dependencies beyond the standard library. It was
forked from the excellent project by @MattKallada, and is in the process of being updated to provide more features and a
(hopefully) simpler and documented API.

For further information regarding general concepts and theory, please see [Selected Publications](http://www.cs.ucf.edu/~kstanley/#publications) on Stanley's website.
For further information regarding general concepts and theory, please see
[Selected Publications](http://www.cs.ucf.edu/~kstanley/#publications) on Stanley's website.

`neat-python` is licensed under the [3-clause BSD license](https://opensource.org/licenses/BSD-3-Clause).

## Getting Started ##

If you want to try neat-python, please check out the repository, start playing with the examples (`examples/xor` is a good place to start) and then try creating your own experiment.
If you want to try neat-python, please check out the repository, start playing with the examples (`examples/xor` is
a good place to start) and then try creating your own experiment.

The documentation, is available on [Read The Docs](http://neat-python.readthedocs.io).

## Citing ##

Here is a Bibtex entry you can use to cite this project in a publication. The listed authors are the maintainers of
all iterations of the project up to this point.

The documentation, which is still a work in progress, is available on [Read The Docs](http://neat-python.readthedocs.io).
```
@misc{neat-python,
Title = {neat-python},
Author = {Alan McIntyre and Matt Kallada and Cesar G. Miguel and Carolina Feher da Silva},
howpublished = {\url{https://github.com/CodeReclaimers/neat-python}}
}
```
Binary file modified docs/activation-abs.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/activation-clamped.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/activation-cube.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/activation-elu.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/activation-exp.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/activation-gauss.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/activation-hat.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/activation-identity.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/activation-inv.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/activation-lelu.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/activation-log.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/activation-relu.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/activation-selu.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/activation-sigmoid.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/activation-sin.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/activation-softplus.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/activation-square.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/activation-tanh.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions docs/activation.rst
Expand Up @@ -85,6 +85,27 @@ relu
:scale: 50 %
:alt: rectified linear function

elu
----

.. figure:: activation-elu.png
:scale: 50 %
:alt: exponential rectified linear function

lelu
----

.. figure:: activation-lelu.png
:scale: 50 %
:alt: leaky rectified linear function

selu
----

.. figure:: activation-selu.png
:scale: 50 %
:alt: scaled exponential linear function

.. _sigmoid-label:

sigmoid
Expand Down
7 changes: 3 additions & 4 deletions docs/conf.py
Expand Up @@ -12,9 +12,8 @@
# All configuration values have a default; values that are commented out
# serve to show the default.

import sys
import os
import shlex
import sys

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
Expand Down Expand Up @@ -68,7 +67,7 @@

# General information about the project.
project = u'NEAT-Python'
copyright = u'2015-2017, CodeReclaimers, LLC'
copyright = u'2015-2019, CodeReclaimers, LLC'
author = u'CodeReclaimers, LLC'

# The version info for the project you're documenting, acts as replacement for
Expand All @@ -81,7 +80,7 @@
release = '0.92'

if version != release:
tags.add('draft')
tags.add('draft')

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
6 changes: 3 additions & 3 deletions examples/circuits/evolve.py
Expand Up @@ -178,10 +178,10 @@ def add_connection(self, config, input_key, output_key):
self.connections[key] = connection

def mutate_add_connection(self, config):
'''
"""
Attempt to add a new connection, the only restriction being that the output
node cannot be one of the network input pins.
'''
"""
possible_outputs = list(iterkeys(self.nodes))
out_node = choice(possible_outputs)

Expand Down Expand Up @@ -273,7 +273,7 @@ def distance(self, other, config):
return distance

def size(self):
'''Returns genome 'complexity', taken to be (number of nodes, number of enabled connections)'''
"""Returns genome 'complexity', taken to be (number of nodes, number of enabled connections)"""
num_enabled_connections = sum([1 for cg in self.connections.values() if cg.enabled is True])
return len(self.nodes), num_enabled_connections

Expand Down
10 changes: 3 additions & 7 deletions examples/circuits/visualize.py
Expand Up @@ -140,17 +140,14 @@ def draw_net(config, genome, view=False, filename=None, node_names=None, show_di
for k in config.genome_config.input_keys:
inputs.add(k)
name = node_names.get(k, str(k))
input_attrs = {'style': 'filled',
'shape': 'box'}
input_attrs['fillcolor'] = node_colors.get(k, 'lightgray')
input_attrs = {'style': 'filled', 'shape': 'box', 'fillcolor': node_colors.get(k, 'lightgray')}
dot.node(name, _attributes=input_attrs)

outputs = set()
for k in config.genome_config.output_keys:
outputs.add(k)
name = node_names.get(k, str(k))
node_attrs = {'style': 'filled'}
node_attrs['fillcolor'] = node_colors.get(k, 'lightblue')
node_attrs = {'style': 'filled', 'fillcolor': node_colors.get(k, 'lightblue')}

dot.node(name, _attributes=node_attrs)

Expand All @@ -177,8 +174,7 @@ def draw_net(config, genome, view=False, filename=None, node_names=None, show_di
if n in inputs or n in outputs:
continue

attrs = {'style': 'filled'}
attrs['fillcolor'] = node_colors.get(n, 'white')
attrs = {'style': 'filled', 'fillcolor': node_colors.get(n, 'white')}
dot.node(str(n), _attributes=attrs)

for cg in genome.connections.values():
Expand Down
2 changes: 2 additions & 0 deletions examples/memory-fixed/clean.bat
@@ -0,0 +1,2 @@
del *.csv *.svg *.gv
del test_save_config.txt
3 changes: 2 additions & 1 deletion examples/memory-fixed/clean.sh
@@ -1,2 +1,3 @@
#!/usr/bin/env bash
rm *.csv *.svg *.gv
rm *.csv *.svg *.gv
rm test_save_config.txt
2 changes: 1 addition & 1 deletion examples/memory-fixed/config
@@ -1,4 +1,4 @@
# NEAT configuration for the bit-sequence memory experiment.
# NEAT configuration for the fixed-length bit-sequence memory experiment.

# The `NEAT` section specifies parameters particular to the NEAT algorithm
# or the experiment itself. This is the only required section.
Expand Down
22 changes: 10 additions & 12 deletions examples/memory-fixed/evolve.py
Expand Up @@ -9,12 +9,14 @@
from __future__ import division, print_function

import math
import multiprocessing
import os
import random

import neat
import visualize

import neat


# Demonstration of how to add your own custom activation function.
# This sinc function will be available if my_sinc_function is included in the
Expand All @@ -26,10 +28,9 @@ def sinc(x):


# N is the length of the test sequence.
N = 3
N = 4
# num_tests is the number of random examples each network is tested against.
num_tests = 2 ** (N+2)

num_tests = 2 ** (N + 2)


def eval_genome(genome, config):
Expand Down Expand Up @@ -81,12 +82,8 @@ def run():
pop.add_reporter(stats)
pop.add_reporter(neat.StdOutReporter(True))

if 1:
pe = neat.ParallelEvaluator(4, eval_genome)
winner = pop.run(pe.evaluate, 1000)
else:
winner = pop.run(eval_genomes, 1000)

pe = neat.ParallelEvaluator(multiprocessing.cpu_count(), eval_genome)
winner = pop.run(pe.evaluate, 1000)

# Log statistics.
stats.save()
Expand All @@ -113,12 +110,13 @@ def run():
print("OK" if correct else "FAIL")
num_correct += 1 if correct else 0

print("{0} of {1} correct {2:.2f}%".format(num_correct, num_tests, num_correct/num_tests))
print("{0} of {1} correct {2:.2f}%".format(num_correct, num_tests, 100.0 * num_correct / num_tests))

node_names = {-1: 'input', -2: 'gate', 0: 'output'}
visualize.draw_net(config, winner, True, node_names=node_names)
visualize.plot_stats(stats, ylog=False, view=True)
visualize.plot_species(stats, view=True)


if __name__ == '__main__':
run()
run()
10 changes: 3 additions & 7 deletions examples/memory-fixed/visualize.py
Expand Up @@ -141,17 +141,14 @@ def draw_net(config, genome, view=False, filename=None, node_names=None, show_di
for k in config.genome_config.input_keys:
inputs.add(k)
name = node_names.get(k, str(k))
input_attrs = {'style': 'filled',
'shape': 'box'}
input_attrs['fillcolor'] = node_colors.get(k, 'lightgray')
input_attrs = {'style': 'filled', 'shape': 'box', 'fillcolor': node_colors.get(k, 'lightgray')}
dot.node(name, _attributes=input_attrs)

outputs = set()
for k in config.genome_config.output_keys:
outputs.add(k)
name = node_names.get(k, str(k))
node_attrs = {'style': 'filled'}
node_attrs['fillcolor'] = node_colors.get(k, 'lightblue')
node_attrs = {'style': 'filled', 'fillcolor': node_colors.get(k, 'lightblue')}

dot.node(name, _attributes=node_attrs)

Expand All @@ -178,8 +175,7 @@ def draw_net(config, genome, view=False, filename=None, node_names=None, show_di
if n in inputs or n in outputs:
continue

attrs = {'style': 'filled'}
attrs['fillcolor'] = node_colors.get(n, 'white')
attrs = {'style': 'filled', 'fillcolor': node_colors.get(n, 'white')}
dot.node(str(n), _attributes=attrs)

for cg in genome.connections.values():
Expand Down
1 change: 1 addition & 0 deletions examples/memory-variable/clean.bat
@@ -0,0 +1 @@
del *.csv *.svg *.gv
12 changes: 6 additions & 6 deletions examples/memory-variable/config
@@ -1,4 +1,4 @@
# NEAT configuration for the bit-sequence memory experiment.
# NEAT configuration for the variable-length bit-sequence memory experiment.

# The `NEAT` section specifies parameters particular to the NEAT algorithm
# or the experiment itself. This is the only required section.
Expand All @@ -12,14 +12,14 @@ reset_on_extinction = 0
num_inputs = 3
num_hidden = 1
num_outputs = 1
initial_connection = partial 0.5
initial_connection = partial_direct 0.5
feed_forward = False
compatibility_disjoint_coefficient = 1.0
compatibility_weight_coefficient = 0.6
conn_add_prob = 0.2
conn_delete_prob = 0.2
node_add_prob = 0.2
node_delete_prob = 0.2
conn_add_prob = 0.1
conn_delete_prob = 0.1
node_add_prob = 0.1
node_delete_prob = 0.1
activation_default = sigmoid
activation_options = sigmoid
activation_mutate_rate = 0.0
Expand Down

0 comments on commit 2ed502b

Please sign in to comment.