You can reset it by changing the argument inside loadModelParameters() function to “nil”.
local function buildActorModel(ID)
local Model = DataPredict.Models.NeuralNetwork.new(1)
Model:setModelParametersInitializationMode("LeCunUniform")
Model:addLayer(5, true, 'LeakyReLU', 0.001)
Model:addLayer(3, true, 'LeakyReLU', 0.001)
Model:addLayer(7, false, 'StableSoftmax', 0.001)
Model:setClassesList({'A','D','W','S','jump','useWeapon', "none"})
local ModelParameters = loadModelParameters(ActorModelDataStore, ID)
Model:setModelParameters(nil) -- Here.
table.insert(ActorModelArray, Model)
return Model
end
local function buildCriticModel(ID)
local Model = DataPredict.Models.NeuralNetwork.new(1)
Model:setModelParametersInitializationMode("LeCunUniform")
Model:addLayer(5, true, 'LeakyReLU', 0.001)
Model:addLayer(3, true, 'LeakyReLU', 0.001)
Model:addLayer(1, false, 'Sigmoid', 0.001)
Model:setClassesList({1, 2})
local ModelParameters = loadModelParameters(CriticModelDataStore, ID)
Model:setModelParameters(nil) -- And here.
table.insert(CriticModelArray, Model)
return Model
end
Don’t forget to put ModelParameters back after you stop the game.
The matrices are nothing more than just a “table of table of numbers”. Anyways, since we are using a neural network model parameters, it will be a table of matrices.
for matrixNumber = 1, #ModelParameters, 1 do
local matrix = ModelParameters[matrixNumber]
for i = 1, #matrix, 1 do -- Rows
for j = 1, #matrix[1], 1 do -- Columns
print(matrix[i][j])
end
end
end
You might have to create your own UI though.
To answer your other question…
Model:setClassesList({1, 2})
This one is just to avoid unexpected bugs. Though, I think you can safely remove it if it bothers you that much.
I’ll give you the full code. This is for main script:
local function onInputReceived(ID, environmentVector, rewardValue)
local Model = ModelArray[ID]
local ActorModel = ActorModelArray[ID]
pcall(function()
local output = Model:reinforce(environmentVector, rewardValue)
local predictedMatrix = ActorModel:predict(environmentVector, true)
MatrixL:printMatrix(predictedMatrix)
OutputEvent:Fire(ID, output)
end)
end
edit: fixed the ui on changing model.
edit 2: fixes, add pause/resume button, better rounding decimal number (specially for negatives) & colored background when decrement/increment.
at addLayer function, u set it as 0.001 so what if i change it to higher like 0.1 or 0.5? it will be faster or slower? also how do you create an optimizer?
If you make the learning rate higher, it will make the training faster, but more likely to have a risk of “untraining” it. I prefer keeping it less than 0.5 if you really want to increase it.
For creating an optimizer, you can have a look at other optimizers that have been created. All of them inherits the BaseOptimizer class.