Note that there are some explanatory texts on larger screens.

plurals
  1. POMLP Neural Network: calculating the gradient (matrices)
    primarykey
    data
    text
    <h1>What is a good implementation for calculating the gradient in a n-layered neural network?</h1> <p><strong>Weight layers:</strong></p> <ol> <li>First layer weights: &nbsp;&nbsp;&nbsp;&nbsp;<code>(n_inputs+1, n_units_layer)-matrix</code></li> <li>Hidden layer weights: <code>(n_units_layer+1, n_units_layer)-matrix</code></li> <li>Last layer weights: &nbsp;&nbsp;&nbsp;&nbsp;<code>(n_units_layer+1, n_outputs)-matrix</code></li> </ol> <p>Notes:</p> <ul> <li>If there is only one hidden layer we would represent the net by using just two (weight) layers:<br> <code>inputs --first_layer-&gt; network_unit --second_layer-&gt; output</code></li> <li>For a n-layer network with more than one hidden layer, we need to implement the (2) step.</li> </ul> <hr> <h3>A bit vague pseudocode:</h3> <pre><code> weight_layers = [ layer1, layer2 ] # a list of layers as described above input_values = [ [0,0], [0,0], [1,0], [0,1] ] # our test set (corresponds to XOR) target_output = [ 0, 0, 1, 1 ] # what we want to train our net to output output_layers = [] # output for the corresponding layers for layer in weight_layers: output &lt;-- calculate the output # calculate the output from the current layer output_layers &lt;-- output # store the output from each layer n_samples = input_values.shape[0] n_outputs = target_output.shape[1] error = ( output-target_output )/( n_samples*n_outputs ) """ calculate the gradient here """ </code></pre> <hr> <h1>Final implementation</h1> <p><a href="https://github.com/jorgenkg/python-neural-network" rel="nofollow">The final implementation is available at github</a>. </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload