I don’t know if I should be using stable or unstable but this code is using unstable:
local Library = require(script.Parent['AqwamRobloxMachineAndDeepLearningLibrary'])
local NeuralNet = Library.Models.NeuralNetwork.new(1,0.01)
local Optimizer = Library.Optimizers.AdaptiveMomentEstimation.new()
NeuralNet:addLayer(1,true,'ReLU',Optimizer)
NeuralNet:addLayer(3,true,'ReLU',Optimizer)
NeuralNet:addLayer(3,true,'ReLU',Optimizer)
NeuralNet:addLayer(2,false,'StableSoftmax',Optimizer)
--NeuralNet:createLayers({1,3,3,2},'ReLU',Optimizer)
NeuralNet:setClassesList({0,1})
local ModifiedModel = Library.Others.GradientDescentModifier.new(NeuralNet)
local featureMatrix = {
{ 0, 0},
{10, 2},
{-3, -2},
{-12, -22},
{ 2, 2},
{ 1, 1},
{-11, -12},
{ 3, 3},
{-2, -2},
}
local labelVectorLogistic = {
{1},
{1},
{0},
{0},
{1},
{1},
{0},
{1},
{0}
}
ModifiedModel:train(featureMatrix,labelVectorLogistic)
local PredictedVector = ModifiedModel:predict({{90, 90}}) -- Should be 1
print(PredictedVector)
print(ModifiedModel:predict({{90, 90}},true))
13:09:51.292 ServerScriptService.MatrixL:105: Argument 1 and 2 are incompatible! (2, 4) and (4, 4) - Server - MatrixL:105
13:09:51.293 Stack Begin - Studio
13:09:51.293 Script 'ServerScriptService.MatrixL', Line 105 - function broadcastAndCalculate - Studio - MatrixL:105
13:09:51.293 Script 'ServerScriptService.MatrixL', Line 117 - function add - Studio - MatrixL:117
13:09:51.293 Script 'ServerScriptService.AqwamRobloxMachineAndDeepLearningLibrary.Optimizers.AdaptiveMomentEstimation', Line 61 - function calculate - Studio - AdaptiveMomentEstimation:61
13:09:51.293 Script 'ServerScriptService.AqwamRobloxMachineAndDeepLearningLibrary.Models.NeuralNetwork', Line 506 - function gradientDescent - Studio - NeuralNetwork:506
13:09:51.293 Script 'ServerScriptService.AqwamRobloxMachineAndDeepLearningLibrary.Models.NeuralNetwork', Line 930 - function train - Studio - NeuralNetwork:930
13:09:51.293 Script 'ServerScriptService.AqwamRobloxMachineAndDeepLearningLibrary.Others.GradientDescentModifier', Line 153 - function startStochasticGradientDescent - Studio - GradientDescentModifier:153
13:09:51.293 Script 'ServerScriptService.AqwamRobloxMachineAndDeepLearningLibrary.Others.GradientDescentModifier', Line 179 - function train - Studio - GradientDescentModifier:179
13:09:51.293 Script 'ServerScriptService.aqwamtestscript', Line 43 - Studio - aqwamtestscript:43
13:09:51.293 Stack End - Studio
And when I switch the “2” to “1” in the output layer it gives me the same error saying the number of classes is not equal to the number of output neurons or something.
Edit: Strange, I just tried that again and now it’s giving me the same error above instead of “the number of classes not being equal to the number of output neurons error.”