Hello, recently I have started to look into Neural netwrosk and I have finally decided to create my first one. It is meant to predict your/my gender based on height and weight, unfortunelyy i could not find an api with large data on female and males weight and height to I have just created a view table containing
their weight in kg, their height in cm and gender 1 as male and 0 as female.
Thats some context the real issue is I am passing the sum of the two imputs and weights plus bias into a sigmoid function, but it is still returing values that are larger than 1 and smaller than zero.
Here is my sigmoid function:
local S = function(x)
return 1 / (1 + math.exp(-x))
end
And this is the rest of my code:
local S = function(x)
return 1 / (1 + math.exp(-x))
end
local Randomnew = Random.new()
local w1 = Randomnew:NextNumber(0, 1)
local w2 = Randomnew:NextNumber(0, 1)
local b = Randomnew:NextNumber(0, 1)
local r = .1
local Perceptron = function(Inputs, Output)
local h1 = S(w1 * Inputs[1] + w2 * Inputs[2] + b)
warn(h1)
if Output then
local loss = Output - h1
w1 += loss * Inputs[1] * r
w2 += loss * Inputs[2] * r
end
return h1
end
local Averages = {
--Males:
{
184,
87.9,
1
},
{
183,
90.4,
1
},
{
182,
89.9,
1
},
{
182,
86.8,
1
},
{
182,
87.1,
1
},
--Females:
{
170,
73.2,
0
},
{
170,
75.3,
0
},
{
168,
73.7,
0
},
{
169,
70.2,
0
},
{
167,
70.6,
0
}
}
local MyGender = Perceptron({
176,
60.2
})
print("Before:", MyGender)
for Index = 1, 100 do
table.foreachi(Averages, function(_, Value)
Perceptron(Value, Value[3])
end)
end
local MyGender = Perceptron({
176,
80.2
})
print("After:", MyGender)
Basically I do not understand why I am getting large and negative values eveen though they have been based through my sigmoid function
Any help at all is appreciated thanks.
