view randInitializeWeights.m @ 3:8e8089d5a55b

Implement randInitializeWeights
author Jordi Gutiérrez Hermoso <jordigh@octave.org>
date Fri, 11 Nov 2011 14:30:29 -0500
parents 395fc40248c3
children 08072e7b3e9f
line wrap: on
line source

function W = randInitializeWeights(L_in, L_out)
  ##RANDINITIALIZEWEIGHTS Randomly initialize the weights of a layer with L_in
  ##incoming connections and L_out outgoing connections
  ##   W = RANDINITIALIZEWEIGHTS(L_in, L_out) randomly initializes the weights 
  ##   of a layer with L_in incoming connections and L_out outgoing 
  ##   connections. 
  ##
  ##   Note that W should be set to a matrix of size(L_out, 1 + L_in) as
  ##   the first row of W handles the "bias" terms
  ##

  ## Randomly initialize the weights to small values
  epsilon init = 0.12;
  W = rand(L out, 1 + L in) * 2 * epsilon init  epsilon init;

endfunction