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

Add balanced random network example using evolution strategies #881

Merged
merged 4 commits into from Mar 28, 2018

Conversation

Projects
None yet
4 participants
@jakobj
Contributor

jakobj commented Jan 16, 2018

This new example builds on the balanced random network example (brunel_alpha_nest.py) to demonstrate how to use evolution strategies to tune the parameters of a network model to optimize a given fitness function. Here we optimize the network to have certain rates, coefficients of variation and correlations.

Note that this is not an implementation striving for maximum performance, but for maximum clarity. For example, it does not make use of multi threading. Nevertheless I believe it is useful to demonstrate how to use standard optimization techniques to optimize network parameters.

The following shows an optimization of the network for 40 generations, to have the following activity statistics: Rate: 1.89, cv: 1, correlation: 0

The fitness grew from -5340 to -2.3, achieving the following activity statistics:
Rate: 1.775, cv: 0.541, correlation: 0.001

The full output reads:

# Generation 0 | fitness -5340.949 | mu 1.0, 3.0 | sigma 0.15, 0.05
# Generation 1 | fitness -4847.064 | mu 1.246, 2.876 | sigma 0.138, 0.054
# Generation 2 | fitness -4361.933 | mu 1.085, 2.714 | sigma 0.154, 0.062
# Generation 3 | fitness -3698.488 | mu 1.091, 2.511 | sigma 0.146, 0.077
# Generation 4 | fitness -3252.178 | mu 1.047, 2.363 | sigma 0.136, 0.084
# Generation 5 | fitness -2463.288 | mu 0.908, 2.086 | sigma 0.131, 0.095
# Generation 6 | fitness -1953.073 | mu 0.988, 1.905 | sigma 0.128, 0.099
# Generation 7 | fitness -1343.387 | mu 1.106, 1.668 | sigma 0.128, 0.106
# Generation 8 | fitness -797.923 | mu 1.168, 1.418 | sigma 0.126, 0.109
# Generation 9 | fitness -134.683 | mu 1.125, 0.985 | sigma 0.126, 0.132
# Generation 10 | fitness -13.572 | mu 1.3, 0.682 | sigma 0.121, 0.126
# Generation 11 | fitness -20.315 | mu 1.264, 0.772 | sigma 0.123, 0.13
# Generation 12 | fitness -12.487 | mu 1.174, 0.662 | sigma 0.13, 0.123
# Generation 13 | fitness -28.238 | mu 1.339, 0.86 | sigma 0.139, 0.149
# Generation 14 | fitness -18.507 | mu 1.369, 0.798 | sigma 0.139, 0.138
# Generation 15 | fitness -40.784 | mu 1.373, 0.798 | sigma 0.134, 0.135
# Generation 16 | fitness -35.668 | mu 1.326, 0.847 | sigma 0.134, 0.1
# Generation 17 | fitness -26.581 | mu 1.405, 0.917 | sigma 0.149, 0.061
# Generation 18 | fitness -9.337 | mu 1.387, 0.855 | sigma 0.146, 0.051
# Generation 19 | fitness -7.494 | mu 1.613, 0.918 | sigma 0.148, 0.047
# Generation 20 | fitness -11.334 | mu 1.85, 0.885 | sigma 0.14, 0.047
# Generation 21 | fitness -13.297 | mu 1.857, 0.901 | sigma 0.134, 0.036
# Generation 22 | fitness -3.587 | mu 1.833, 0.887 | sigma 0.137, 0.021
# Generation 23 | fitness -5.279 | mu 1.982, 0.909 | sigma 0.137, 0.02
# Generation 24 | fitness -4.934 | mu 1.889, 0.875 | sigma 0.125, 0.018
# Generation 25 | fitness -3.631 | mu 1.737, 0.902 | sigma 0.118, 0.018
# Generation 26 | fitness -3.467 | mu 1.798, 0.888 | sigma 0.116, 0.017
# Generation 27 | fitness -4.857 | mu 1.781, 0.914 | sigma 0.115, 0.015
# Generation 28 | fitness -2.630 | mu 1.759, 0.896 | sigma 0.115, 0.014
# Generation 29 | fitness -3.812 | mu 1.656, 0.901 | sigma 0.126, 0.013
# Generation 30 | fitness -2.319 | mu 1.575, 0.893 | sigma 0.115, 0.009
# Generation 31 | fitness -2.536 | mu 1.583, 0.903 | sigma 0.102, 0.009
# Generation 32 | fitness -2.631 | mu 1.64, 0.889 | sigma 0.106, 0.009
# Generation 33 | fitness -2.485 | mu 1.725, 0.903 | sigma 0.104, 0.009
# Generation 34 | fitness -2.840 | mu 1.693, 0.893 | sigma 0.12, 0.008                         
# Generation 35 | fitness -2.423 | mu 1.68, 0.902 | sigma 0.115, 0.006                                                               
# Generation 36 | fitness -2.773 | mu 1.699, 0.888 | sigma 0.11, 0.005                                                                                        
# Generation 37 | fitness -2.069 | mu 1.731, 0.901 | sigma 0.104, 0.006                                                                                 
# Generation 38 | fitness -2.217 | mu 1.704, 0.896 | sigma 0.11, 0.006                                                                                        
# Generation 39 | fitness -2.132 | mu 1.821, 0.9 | sigma 0.138, 0.005                                                                                         
# Generation 40 | fitness -2.347 | mu 1.69, 0.892 | sigma 0.121, 0.004                                                                                          
Statistics after optimization: Rate: 1.775, cv: 0.541, correlation: 0.001

The script generates the following plot, illustrating the search and activity in the final network:
brunel_alpha_evolution_strategies

I suggest @sdiazpier and @jessica-mitchell as reviewers

Add balanced random network example using evolution strategies
This new example builds on the balanced random network
example (brunel_alpha_nest.py) to demonstrate how to use evolution
strategies to tune the parameters of a network model to optimize a
given fitness function. Here we optimize the network to have certain
rates, coefficients of variation and correlations.
@jessica-mitchell

From a documentation standpoint, this looks really good. I would like to suggest you include a couple of lines at the beginning, similar to what you said in your comment ("This new example builds on the balanced random network example (brunel_alpha_nest.py) to demonstrate how to use evolution strategies to tune the parameters of a network model to optimize a given fitness function. Here we optimize the network to have certain rates, coefficients of variation and correlations."), as I think it as nice explanation to why a user may want to use this example. Second, I think including the brunel_alpha_nest.py under a See Also header would be best - this will make related examples and functions more easily discoverable. In the very near future, we hope to get to a more standardized layout for the documentation of these scripts.

@terhorstd terhorstd requested a review from sdiazpier Jan 22, 2018

@terhorstd terhorstd added this to the NEST 2.16 milestone Mar 5, 2018

@terhorstd terhorstd requested review from heplesser and removed request for sdiazpier Mar 5, 2018

@heplesser

@jakobj This is a very nice example. I would still like to ask you for some additions to the documentation: In the introduction, it would be nice to have a brief description of the search algorithm and cost function, especially the weighting of the different criteria. It might also be a good idea to comment the parameters to the functions; at present, one finds a lot of important information only towards the end of the script.

@jakobj

This comment has been minimized.

Show comment
Hide comment
@jakobj

jakobj Mar 23, 2018

Contributor

I've updated the documentation, please have another look.

Contributor

jakobj commented Mar 23, 2018

I've updated the documentation, please have another look.

@heplesser

This comment has been minimized.

Show comment
Hide comment
@heplesser

heplesser Mar 23, 2018

Contributor

@jessica-mitchell Could you have another look?

Contributor

heplesser commented Mar 23, 2018

@jessica-mitchell Could you have another look?

@jessica-mitchell

Looks good - I just have a few minor comments:

line 26 - misspelled appropriate
line 33 - do you need to use the term 'individuals' - since you go on to use networks in the next sentence?

line 51 - please use the bibliography style used in line 57 (Wiesrtra) for the Brunel reference so they are consistent.

line 60: please remove ' based on brunel_alpha_nest.py' and add a new line that says 'See Also: brunel_alpha_nest.py'

line 133/134 - unsure if population should be singular or plural; please add 'an' before excitatory if singular or add 's' to population if plural

line 296 - add 'the' before words mean and search

line 304 - please add 'the' before standard and search

line 360 - misspelled search

line 369 - misspelled continuously

@jakobj

This comment has been minimized.

Show comment
Hide comment
@jakobj

jakobj Mar 28, 2018

Contributor

Thanks @jessica-mitchell for the helpful comments. I've included them now.

Contributor

jakobj commented Mar 28, 2018

Thanks @jessica-mitchell for the helpful comments. I've included them now.

@jessica-mitchell

Great, thanks

@heplesser heplesser merged commit ec221ef into nest:master Mar 28, 2018

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment