Not showing output in command window of 'testing' script.

3 ビュー (過去 30 日間)
AVINASH SAHU
AVINASH SAHU 2021 年 12 月 26 日
コメント済み: AVINASH SAHU 2021 年 12 月 27 日
SIGMOID FUNCTION
function y = Sigmoid(x)
y = 1/(1 + exp(-x));
end
SGD Method function
function Weight = SGD_method(Weight, input, correct_Output)
alpha = 0.9;
N = 4;
for k = 1:N
transposed_Input = input(k, :)';
d = correct_Output(k);
weighted_Sum = Weight*transposed_Input;
output = Sigmoid(weighted_Sum);
error = d - output;
delta = output*(1-output)*error;
dWeight = alpha*delta*transposed_Input;
Weight(1) = Weight(1) + dWeight(1);
Weight(2) = Weight(2) + dWeight(2);
Weight(3) = Weight(3) + dWeight(3);
end
end
Training script
input = [ 0 0 1;
0 1 1;
1 0 1;
1 1 1;
];
correct_Output = [0
0
1
1
];
Weight = 2*rand(1 , 3) - 1;
for epoch = 1:10000
Weight = SGD_method(Weight, input, correct_Output);
end
save('Trained_Network.mat')
Testing script
load('Trained_Network.mat');
input = [ 0 0 1;
0 1 1;
1 0 1;
1 1 1;
];
N = 4;
for k = 1:N
transposed_Input = input(k, :)';
weighted_Sum = Weight*transposed_Input;
output = Sigmoid(weighted_Sum);
end

採用された回答

Voss
Voss 2021 年 12 月 26 日
% Testing script
load('Trained_Network.mat');
input = [ 0 0 1;
0 1 1;
1 0 1;
1 1 1;
];
N = 4;
for k = 1:N
transposed_Input = input(k, :)';
weighted_Sum = Weight*transposed_Input;
output = Sigmoid(weighted_Sum)
end
  2 件のコメント
Walter Roberson
Walter Roberson 2021 年 12 月 26 日
Which is to say, that the testing script had no disp() or fprintf(), and that every line in the script that could potentially return a result had the result supressed with the semi-colon .
AVINASH SAHU
AVINASH SAHU 2021 年 12 月 27 日
Thanks for help.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangePattern Recognition and Classification についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by