The RNN codes are based on Python 3.6.5 and Tensorflow 1.8.0

This folder contains code for the adaptation task (figs.1-2 in main text)

The output folder '1' is generated by running the file 'adapt_2020_1_NN.py' with the output folder name provided as the input argument '--run_num 1'.
'1/loss.csv' records the decreasing of the training error.
'1/train' contains some example outputs during training. 
'1/savenet' contains the Tensorflow checkpoint files.
'1/paras' contains the NN parameters (weights and bias). 

Test output trajectories under 20 different stimuli strengths are written to the 'trajs' folder by running 'adapt_2020_1_NN_test_traj.py --run_num 1'.
The output file 'trajs/run*_traj_g*.csv' contains a [20,T] matrix, with each row represents one of the 20 different test cases.


To run 'adapt_2020_2_NN.py', an input file (e.g. '1/links.csv') that defines the allowed regulatory links should be provided in the output directory.

After training, the 'adapt_2020_2_NN_link_ko.py' program is used to find an effective regulation network with the "link mutation" technique. The input arguments are: 
'--run_num' specifies the directory of the trained NN.
'--lambda_factor' defines the discount factor for link mutaion test (see equation 3 in the main text). 
When run on the output folder '--run_num $n', this program writes the effective regulation network as 'nets/run$n.csv', and generates a new "allowed link" file at 'n+1/links.csv' where the least relevant link is removed.
'--keep_input_links' switch between two mode for determining "the least relevant link". If it equals to 1, the links from the inpiut stimuli "I" to the other nodes "gs" will never be removed, no matter how weak it appears to be. This function will not be activated if this argument is set to 0 (as default).

The results in folders 1-6 corresponds to fig.2c; and results 101-105 corresponds to fig.2d.