Skip to content

Instantly share code, notes, and snippets.

@gognjanovski
Last active December 14, 2018 12:47
Show Gist options
  • Save gognjanovski/e42ce8366c0f45e424b5549eefbc3e32 to your computer and use it in GitHub Desktop.
Save gognjanovski/e42ce8366c0f45e424b5549eefbc3e32 to your computer and use it in GitHub Desktop.
...
options = optimset('MaxIter', 100);
...
% Now, costFunction is a function that takes in only one argument (the
% neural network parameters)
[nn_params, cost] = fmincg(costFunction, initial_nn_params, options);
% Obtain Theta1 and Theta2 back from nn_params
Theta1 = reshape(nn_params(1:hidden_layer_size * (input_layer_size + 1)), ...
hidden_layer_size, (input_layer_size + 1));
Theta2 = reshape(nn_params((1 + (hidden_layer_size * (input_layer_size + 1))):end), ...
num_labels, (hidden_layer_size + 1));
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment