dibgerge / ml-coursera-python-assignments

Python assignments for the machine learning class by andrew ng on coursera with complete submission for grading capability and re-written instructions.
5.44k stars 2.15k forks source link

Exercise 3 in 2.1 np.roll is used to change 1st row with last not first column with last column #80

Open bilalayaz2 opened 3 years ago

bilalayaz2 commented 3 years ago

`

  1. //Setup the parameters you will use for this exercise
  2. input_layer_size = 400 // 20x20 Input Images of Digits
  3. hidden_layer_size = 25 // 25 hidden units
  4. num_labels = 10 // 10 labels, from 0 to 9
  5. 6.//Load the .mat file, which returns a dictionary

  6. weights = loadmat(os.path.join('Data', 'ex3weights.mat'))
  7. //get the model weights from the dictionary
  8. // Theta1 has size 25 x 401
  9. //Theta2 has size 10 x 26
  10. Theta1, Theta2 = weights['Theta1'], weights['Theta2']
  11. //swap first and last columns of Theta2, due to legacy from MATLAB indexing,
  12. //since the weight file ex3weights.mat was saved based on MATLAB indexing
  13. Theta2 = np.roll(Theta2, 1, axis=0)

` here we are swapping first and last row not column (as stated in line 14 [which is incorrect]) with axis = 0 (in line 16) not column .