-1

I am a beginner to machine learning and octave. I am trying to write a code in octave that would calculate the sigmoid function g(z)=g(z)=1./(1+exp(-(z)));

When I try to find g(0) or g(-5) I get this error message:error: g(-5): subscripts must be either integers 1 to (2^63)-1 or logicals.

How do I resolve this, please?

Thanks so much in advance, for your help.

  • Please show your code. We cannot say why your code is wrong if we cannot see it. – Cris Luengo May 02 '20 at 13:40
  • `g(z)=g(z)=1./(1+exp(-(z)));` is not the correct syntax for defining a function in octave. Have a look here: https://octave.org/doc/v5.2.0/Functions-and-Scripts.html#Functions-and-Scripts – Tasos Papastylianou May 02 '20 at 23:12

1 Answers1

1

I have no clue why you encountered that error. When I tried the code below, it seems working well

g = @(z) 1./(1+exp(-z));

Example

>> g(-5)
ans =  0.0066929
>> g(0)
ans =  0.50000
>> g(5)
ans =  0.99331
ThomasIsCoding
  • 96,636
  • 9
  • 24
  • 81
  • I guess she created something that Octave sees as Matrix or Vector. https://octave.org/doc/v5.2.0/Functions-and-Scripts.html#Functions-and-Scripts – matzeri May 02 '20 at 11:50
  • @matzeri well...probably as you guessed. Let's wait for further information from OP – ThomasIsCoding May 02 '20 at 11:53