help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

error: value on right hand side of assignment is undefined


From: andetroy
Subject: error: value on right hand side of assignment is undefined
Date: Fri, 7 Aug 2020 02:44:43 -0500 (CDT)

I have been attempting to run a script that calls a function but I keep
getting the following error: "value on right hand side of assignment is
undefined". The script and function code are shown below respectively.

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)
endfor

save('Trained_Network.mat')


the function

function 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);
  endfor
endfunction


Please provide assistance

Thanks



--
Sent from: https://octave.1599824.n4.nabble.com/Octave-General-f1599825.html



reply via email to

[Prev in Thread] Current Thread [Next in Thread]