debugInitializeWeights.m 841 B

12345678910111213141516171819202122
  1. function W = debugInitializeWeights(fan_out, fan_in)
  2. %DEBUGINITIALIZEWEIGHTS Initialize the weights of a layer with fan_in
  3. %incoming connections and fan_out outgoing connections using a fixed
  4. %strategy, this will help you later in debugging
  5. % W = DEBUGINITIALIZEWEIGHTS(fan_in, fan_out) initializes the weights
  6. % of a layer with fan_in incoming connections and fan_out outgoing
  7. % connections using a fix set of values
  8. %
  9. % Note that W should be set to a matrix of size(1 + fan_in, fan_out) as
  10. % the first row of W handles the "bias" terms
  11. %
  12. % Set W to zeros
  13. W = zeros(fan_out, 1 + fan_in);
  14. % Initialize W using "sin", this ensures that W is always of the same
  15. % values and will be useful for debugging
  16. W = reshape(sin(1:numel(W)), size(W)) / 10;
  17. % =========================================================================
  18. end