Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

getting _G440 instead of wanted answer

Status
Not open for further replies.

Loic2000

Technical User
Jul 22, 2001
1
GB
hello, I'm making a program that is supposed to imitate a simple neurone. The idea is that after it has calculated the net input, it decides if the neurone will be activated or not, if the activation level is greater than 0 then it will, otherwise it will not be activated. I think it might be working OK, but it gives me the wrong type of answer, it's giving a number like _G440 instead. Here it is:

neuron([],[],Bias,Bias).
neuron([Input|InputTail],[Weight|WeightTail],Bias,Result):-
neuron(InputTail,WeightTail,Bias,Temp);
Temp2 is Temp + Input*Weight,
Temp2 > 0 -> Result = 1; Temp2 =< 0 -> Result = 0.

Where have I gone wrong? I'm new to this, so please forgive me if I've done something really dumb. Thanks for your time.
 
Um....even though the activation fuction is kind of odd...and you didn't seem do use the variable 'bias', here is a possible solution ....

neuron([Input|InputTail],[Weight|WeightTail],Result):-neuron([Input|InputTail],[Weight|WeightTail],Result,0).
neuron([Input|InputTail],[Weight|WeightTail], Result, Temp):-
Temp2 is Temp + Input*Weight, neuron(InputTail,WeightTail,Result,Temp2).
neuron([],[], Result,Temp):-(Temp > 0 -> Result = 1; Temp =< 0 -> Result = 0).

?- neuron([1,2],[0.2,0.9], Result).

Result = 1

Yes
?- neuron([1,2],[0.2,-0.9], Result).

Result = 0 ;

No
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top