Why error function not work?

The error function doesn't work with me. I do not get any result.
If anyone knows the problem, I will be thankful
for j1=1:3,
yi=w'*x(:,j1); % Network output
y=sign(yi);
if sum(y-d(1,:)') > 0
error=error+1
end
end

8 Commenti

madhan ravi
madhan ravi il 15 Nov 2018
Modificato: madhan ravi il 15 Nov 2018
w',x,d?? , provide the values
Amna El-tawil
Amna El-tawil il 15 Nov 2018
w'>> the weight
x>> input
d>> desired output
There is the full code, but I get stuck in this part of the code.
w=2*rand(ni,no)-1; % Randomly choosen between -1 and 1
% Characters,
x=[
5 55 14 32;
4 4 84 5;
4 31 9 4;
4 45 99 2];
% Desired outputs, row one is for C, two is for L etc...
d=[
1, 1, 0 ;
0, 1, 0 ;
0, 0, 1 ];
madhan ravi
madhan ravi il 15 Nov 2018
size(y) is 4 by 1 and size(d(1,:)') is 3 by 1 how can you subtract them?
Amna El-tawil
Amna El-tawil il 15 Nov 2018
When I run the code, this is the size of y and d:
size(y) is 4 by 3
size(d) is 3 by 3
d(1,:)' >>> means first row all columns
The apostrophe transposes that output of d:
size(d(1,:)) % -> [1 3]
size(d(1,:)') % -> [3 1]
So neither will actually fit.
What are you trying to do? If you give a good description of your problem, we can try to help you with that, instead of fixing code that might not do what you mean.
Guillaume
Guillaume il 15 Nov 2018
Modificato: Guillaume il 15 Nov 2018
It is very unlikely that the code shown does whatever it is required to do. The whole thing doesn't make sense. Of course, if the code was commented as it should be, we would have an idea of what it was supposed to do (hint!).
Note:
Madhan: size(y) is 4 by 1
Amna: size(y) is 4 by 3
size(y) is always going to be size(w, 2) by 1. It can't have 3 columns since the multiplication in w' * x(:, 1) guarantees it will have one column. It will has as many rows as w has column, which is no whose value was not given. If no is 3 the subtraction will succeed. ni has to be 4 for the multiplication to work.
Also note that naming a variable error is a bad idea. It's already the name of a matlab function.
madhan ravi
madhan ravi il 15 Nov 2018
Perfect explanation @Guillaume

Accedi per commentare.

Risposte (0)

Categorie

Scopri di più su Loops and Conditional Statements in Centro assistenza e File Exchange

Tag

Richiesto:

il 15 Nov 2018

Commentato:

il 15 Nov 2018

Community Treasure Hunt

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

Start Hunting!

Translated by