项目作者: tomgrek

项目描述 :
Conway's Game of Life, in PyTorch, using convolutions
高级语言: Python
项目地址: git://github.com/tomgrek/gameoflife.git
创建时间: 2020-01-17T04:53:03Z
项目社区:https://github.com/tomgrek/gameoflife

开源协议:

下载


Learnable Game Of Life (John Conway) with convolutions, in PyTorch

Learnable cellular automata… in PyTorch, using convolutions.

Just a fun thing to try. Documented @tomgrek/evolving-game-of-life-neural-networks-chaos-and-complexity-94b509bc7aa8">here.

Instructions

  1. Run python3 life.py just to see the basic game in action. Press q to exit.

A basic game run according to the rules

  1. Run python3 lifedatagen.py to start collecting some training data. Press q to exit once it gets fairly stable/boring.
    2a. Edit the code of lifedatagen.py at change line 21 from if False: to if True:. The first time you run the script,
    it creates a new file (a numpy vector). The second time it’ll append to that vector instead (provided you make the change.)
    2b. Run python3 lifedatagen.py several more times to gather training examples.
    2c. You should see a file called train.data has been created.

  2. Run python3 lifeshuffle.py. This takes train.data, shuffles it, and removes discontinuities from when you exited/restarted in step 2b above.

  3. Run python3 lifetrain.py. This trains the network. Once training is done (GPU required, likely only 5-10 minutes) it’ll run the modelled game and display it. Press q to quit or r to restart with a new randomly initialized board. Some params like learning rate, num epochs can be edited inside that file.

Here’s an example output:

A learned game