randInitializeWeights.m 1019 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. function W = randInitializeWeights(L_in, L_out)
  2. %RANDINITIALIZEWEIGHTS Randomly initialize the weights of a layer with L_in
  3. %incoming connections and L_out outgoing connections
  4. % W = RANDINITIALIZEWEIGHTS(L_in, L_out) randomly initializes the weights
  5. % of a layer with L_in incoming connections and L_out outgoing
  6. % connections.
  7. %
  8. %%
  9. %
  10. %
  11. %
  12. % Note that W should be set to a matrix of size(L_out, 1 + L_in) as
  13. % the first column of W handles the "bias" terms
  14. %
  15. % You need to return the following variables correctly
  16. % Randomly initialize the weights to small values
  17. epsilon_init = 0.12;
  18. W = rand(L_out, 1 + L_in) * 2 * epsilon_init - epsilon_init;
  19. % ====================== YOUR CODE HERE ======================
  20. % Instructions: Initialize W randomly so that we break the symmetry while
  21. % training the neural network.
  22. %
  23. % Note: The first column of W corresponds to the parameters for the bias unit
  24. %
  25. % =========================================================================
  26. end