-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathcost_fn.m
More file actions
35 lines (26 loc) · 1.09 KB
/
cost_fn.m
File metadata and controls
35 lines (26 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
function [ cost ] = cost_fn( x1, x2, y, act_fn, Wb, nlv )
%{
FUNCTION DESCRIPTION:
---------------------------------------------------------------------------
Compute (least-squares) cost function.
---------------------------------------------------------------------------
INPUTS:
---------------------------------------------------------------------------
x1,x2 -- co-ordinates of training data {vectors},
y -- labels for trianing data {vector},
act_fn -- type of activation function being used {string},
Wb -- weight matrices and bias vectors {cell array},
nlv -- number of nodes in each layer {vector}.
---------------------------------------------------------------------------
OUTPUTS:
---------------------------------------------------------------------------
cost -- value of the cost function {scalar}.
---------------------------------------------------------------------------
Written by: James Rynn
Last edited: 19/03/2020
%}
% Compute individual costs.
costvec = cost_vec(x1, x2, y, act_fn, Wb, nlv);
% Compute total cost from individual costs.
cost = norm(costvec)^2;
end