submit.m 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. function submit()
  2. addpath('./lib');
  3. conf.assignmentSlug = 'neural-network-learning';
  4. conf.itemName = 'Neural Networks Learning';
  5. conf.partArrays = { ...
  6. { ...
  7. '1', ...
  8. { 'nnCostFunction.m' }, ...
  9. 'Feedforward and Cost Function', ...
  10. }, ...
  11. { ...
  12. '2', ...
  13. { 'nnCostFunction.m' }, ...
  14. 'Regularized Cost Function', ...
  15. }, ...
  16. { ...
  17. '3', ...
  18. { 'sigmoidGradient.m' }, ...
  19. 'Sigmoid Gradient', ...
  20. }, ...
  21. { ...
  22. '4', ...
  23. { 'nnCostFunction.m' }, ...
  24. 'Neural Network Gradient (Backpropagation)', ...
  25. }, ...
  26. { ...
  27. '5', ...
  28. { 'nnCostFunction.m' }, ...
  29. 'Regularized Gradient', ...
  30. }, ...
  31. };
  32. conf.output = @output;
  33. submitWithConfiguration(conf);
  34. end
  35. function out = output(partId, auxstring)
  36. % Random Test Cases
  37. X = reshape(3 * sin(1:1:30), 3, 10);
  38. Xm = reshape(sin(1:32), 16, 2) / 5;
  39. ym = 1 + mod(1:16,4)';
  40. t1 = sin(reshape(1:2:24, 4, 3));
  41. t2 = cos(reshape(1:2:40, 4, 5));
  42. t = [t1(:) ; t2(:)];
  43. if partId == '1'
  44. [J] = nnCostFunction(t, 2, 4, 4, Xm, ym, 0);
  45. out = sprintf('%0.5f ', J);
  46. elseif partId == '2'
  47. [J] = nnCostFunction(t, 2, 4, 4, Xm, ym, 1.5);
  48. out = sprintf('%0.5f ', J);
  49. elseif partId == '3'
  50. out = sprintf('%0.5f ', sigmoidGradient(X));
  51. elseif partId == '4'
  52. [J, grad] = nnCostFunction(t, 2, 4, 4, Xm, ym, 0);
  53. out = sprintf('%0.5f ', J);
  54. out = [out sprintf('%0.5f ', grad)];
  55. elseif partId == '5'
  56. [J, grad] = nnCostFunction(t, 2, 4, 4, Xm, ym, 1.5);
  57. out = sprintf('%0.5f ', J);
  58. out = [out sprintf('%0.5f ', grad)];
  59. end
  60. end