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