Skip to content

Commit f707bf7

Browse files
authored
[ADD] cost_function an train algorithm
1 parent d967b30 commit f707bf7

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

cost_function.m

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
function [c,d_c] = cost_function(so,sd)
2+
%COST_FUNCTION Summary of this function goes here
3+
% Detailed explanation goes
4+
5+
c =mean((so-sd).^2);
6+
d_c = so-sd;
7+
end
8+

train.m

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
2+
function [neural_net,y_predicted, learning_rate]= train(neural_net,X,Y,...
3+
cost_function,learning_rate)
4+
5+
%TRAIN Summary of this function goes here
6+
% Detailed explanation goes here
7+
8+
out(1,1:2)={nan,X};
9+
10+
% forward, get z(output) values of all layers.
11+
12+
out = fordwarding(neural_net, out);
13+
14+
%back propagation, modify the weights of the nn.
15+
16+
neural_net = backpropagation(neural_net,cost_function, out, learning_rate, Y);
17+
18+
% la salida se almacena en la última posición de out.
19+
20+
y_predicted = out{end,2};
21+
22+
end
23+

0 commit comments

Comments
 (0)