|
|
| (22 intermediate revisions by 2 users not shown) |
| Line 1: |
Line 1: |
| − | {{DISPLAYTITLE:train_one_net.m}} | + | {{DISPLAYTITLE:train_one_net.m}} __NOTOC__ |
| − | Constructs a MATLAB neural network object and runs the training for a single neural network. The function first generates a unique training library using supplied parameters (see [[deer_lib_gen.m]]), a neural netwok object is then constructed and the training carried out as specified in the input.
| + | Trains a network and writes a file with the specified number. If the specified file exists, the function will load that network file and continue training. |
| − | | |
| − | If there is already a network with the specified name present in the directory, the function will attempt to load that network file and continue training from the checkpoint with a previously unseen training dataset. The function will sequentially train a network against multiple training sets if specified in the input. | |
| | | | |
| | ==Syntax== | | ==Syntax== |
| | | | |
| − | train_one_net(parameters,trsets,file_number)
| + | train_one_net(parameters,batch_size,file_number) |
| | | | |
| − | ==Arguments== | + | ==Parameters== |
| | | | |
| − | parameters - structure containing training library
| + | parameters - library and network specification struc- |
| − | and network design specifications.
| + | ture (see [[deer_lib_gen.m]]) |
| | | | |
| − | trsets - size of training database to use in
| + | batch_size - the number of training examples randomly |
| − | training. May be supplied as a horizontal
| + | generated at each iteration; must fit in |
| − | vector to allow sequential training with
| + | memory |
| − | multiple databases.
| |
| − |
| |
| − | file_number - number used as an identifier for
| |
| − | saving the network object.
| |
| − | | |
| − | Three further fields are required in the parameters structure, in order to specify the neural network design:
| |
| − | | |
| − | parameters.layer_sizes - number of neurons per layer, expected
| |
| − | as a horizontal vector where the number
| |
| − | of elements is the number of hidden
| |
| − | layers desired.
| |
| | | | |
| − | parameters.lastlayer - activation function to use in the
| + | file_number - the network object will be saved into a |
| − | neural network output layer.
| + | file with this number as the name |
| − |
| |
| − | parameters.method - neural network training algorithm
| |
| − | selection.
| |
| | | | |
| | ==Outputs== | | ==Outputs== |
| − | The only output produced by this function is the network, saved as '''"file_number".mat''' in the working directory.
| + | This function writes a MAT file with the network object and the parameters structure. |
| − | | |
| − | ==Examples==
| |
| − | The example below will train a single network using the parameters described in the [[netset_params.m]] file for the network ensemble optimized for any peak width.
| |
| − | | |
| − | This example can be run from within '''examples/deernet/''':
| |
| − | | |
| − | % Load training set parameters
| |
| − | run('net_set_any_peaks/netset_params.m');
| |
| − |
| |
| − | % Specify the sizes of training databases to train against
| |
| − | trsets=[160e4 160e4 160e4 160e4];
| |
| − |
| |
| − | % Run the network training for a a single network
| |
| − | train_one_net(parameters,trsets,111);
| |
| − | | |
| − | The function will save the output file "111.mat" to the working directory.
| |
| − | | |
| − | '''NOTE:''' For the network and training set dimensions used here, a high performance Nvidia GPU is required (e.g. Nvidia Tesla K40). Training set sizes may be decreased to fit on available hardware but this will sacrifice performance of the trained model.
| |
| | | | |
| | ==Notes== | | ==Notes== |
| − | '''Computing resources'''
| + | # A strong NVidia GPU is required - at least a Titan V |
| − | | + | # If the file pre-exists, the network will be loaded and used as the initial guess. |
| − | The function requires at least one Nvidia GPU, multiple GPUs will be used where available.
| |
| − | | |
| − | | |
| − | '''Selected network design parameters'''
| |
| − | | |
| − | '''''parameters.layer_sizes'''''
| |
| − | | |
| − | This parameter is used to specify the number of hidden layers and the number of neurons per layer:
| |
| − | *the number of neurons in the first layer must be equal to the point count used in the training set ([[Neural network module#Training parameters structure|parameters.npoints]]),
| |
| − | *when the network is constructed, a final "output" layer is automatically added to the network. The number of neurons in this layer is set to be equal to the length of the output vector during training,
| |
| − | *any number and any size of intermediate layers may be specified in the parameters, we have found that networks with uniform intermediate layer achieve the best practical performance,
| |
| − | **the training process may be slightly sped up by using intermediate layers with fewer neurons, but any reduction in the dimensions comes with some degredation of network performance.
| |
| − | | |
| − | '''''parameters.lastlayer'''''[[File:logsig.png|thumb|200x150px|logsig activation function]]
| |
| − | | |
| − | This parameter is used to select the activation function for the neurons in the final layer, we suggest the Logistic Sigmoid (<span id="logsig_func">'logsig'</span>) activation function is used.
| |
| − | | |
| − | *The distance distribution is a non-negative function, we have found that including this knowledge at the network level by using the non-negative Logistic Sigmoid activation function results in better performance and faster training (see supplementary Table S1 of our [https://dx.doi.org/10.1126/sciadv.aat5218 paper]).
| |
| − | | |
| − | '''''parameters.method'''''
| |
| − | | |
| − | This parameter is used to select the training algorithm to employ in training. We suggest using either RPROP or SCG-BP:
| |
| − | *'''RPROP''' (MATLAB [https://uk.mathworks.com/help/nnet/ref/trainrp.html 'trainrp'])- resilient backpropagation algorithm of Riedmiller and Braun.[https://dx.doi.org/10.1109/ICNN.1993.298623]
| |
| − | *'''SCG-BP'''(MATLAB [https://uk.mathworks.com/help/nnet/ref/trainscg.html 'trainscg'])- scaled conjugate gradient backpropagation algorithm of Martin Møller.[https://doi.org/10.7146/dpb.v19i339.6570]
| |
| − | | |
| − | | |
| − | '''Default network design parameters'''
| |
| − | | |
| − | The parameters below are set to default values:
| |
| − | | |
| − | '''''Hidden layer activation function'''''[[File:tansig.png|thumb|200x150px|tansig activation function]]
| |
| − | | |
| − | The hyperbolic tangent sigmoid (<span id="tansig_func">'tansig'</span>) activation function is used in the intermediate layers.
| |
| − | | |
| − | '''''Performance function and weight regularization'''''
| |
| − | | |
| − | The sum of squared errors (SSE) performance function is used, modified to penalise large learned network parameters by adding a sum of the squared weights term.
| |
| − | | |
| − | This method is called ''weight regularization'' (or shrinkage) and is used to avoid overfitting to the training data.
| |
| − | | |
| − | '''''Stopping criteria and data division'''''
| |
| − | | |
| − | The ''early stopping'' technique is used. The training database is divided into two subsets:
| |
| − | *Training set (70%) - used for training the network.
| |
| − | *Validation set(30%) - monitored during training in order to avoid overfitting of the network to the training set.
| |
| − | Training is stopped when the error on the validation set increases for 100 iterations while the error on the training set continues to decrease.
| |
| − | | |
| − | '''''Data pre- and post-processing'''''
| |
| − | | |
| − | Training data is generated ready for use (see [[deer_lib_gen.m]]). No pre- or post-processing of the training data is included at the the neural network level.
| |
| | | | |
| | ==See also== | | ==See also== |
| − | '''Functions used'''
| + | [[deer_lib_gen.m]], [[deernet.m]], [[dist_range.m]], [[elexsys2deernet.m]], [[process_using.m]], [[Neural network module]], [[Built-in_experiments]] |
| − | | |
| − | [[deer_lib_gen.m]], [[netset_params.m]] | |
| − | | |
| − | '''Other related functions'''
| |
| − | | |
| − | [[deernet.m]], [[netset_curate.m]], [[process_using.m]] | |
| − | | |
| − | ==References==
| |
| − | [1] M. Riedmiller, H. Braun, A Direct Adaptive Method for Faster Backpropagation | |
| − | Learning: The RPROP Algorithm, in ''IEEE International Conference on Neural Networks'',
| |
| − | IEEE, San Francisco, '''1993''', vol. 1,pp. 586-591.
| |
| − | | |
| − | [2] Moller, A Scaled Conjugate Gradient Algorithm for Fast Supervised Learning, ''Neural Networks'', Vol. 6, '''1993''', pp. 525–533
| |
| − | | |
| | | | |
| − | ''Version 2.2, authors: [[Ilya Kuprov]], [[Steve Worswick]]'' | + | ''Version 2.8, authors: [[Ilya Kuprov]], [[Steve Worswick]], [[Jake Keeley]], [[Tajwar Choudhury]]'' |