self.module = module
self.criterion = criterion
self.verbose = true
+ self.logger = function(s)
+ print(s)
+ end
end
function StochasticGradient:train(dataset)
end
end
- print("# StochasticGradient: training")
+ self.logger("# StochasticGradient: training")
while true do
local currentError = 0
end
if self.verbose then
- print("# current error = " .. currentError)
+ self.logger("# current error = " .. currentError)
end
iteration = iteration + 1
currentLearningRate = self.learningRate/(1+iteration*self.learningRateDecay)
if self.maxIteration > 0 and iteration > self.maxIteration then
- print("# StochasticGradient: you have reached the maximum number of iterations")
- print("# training error = " .. currentError)
+ self.logger("# StochasticGradient: you have reached the maximum number of iterations")
+ self.logger("# training error = " .. currentError)
break
end
end
trainer.learning_rate = rule.train.learning_rate
trainer.verbose = false
trainer.maxIteration = rule.train.max_iterations
- trainer.hookIteration = function(self, iteration, currentError)
+ trainer.hookIteration = function(_, iteration, currentError)
rspamd_logger.infox(rspamd_config, "learned %s iterations, error: %s",
iteration, currentError)
end
-
+ trainer.logger = function(s)
+ rspamd_logger.infox(rspamd_config, 'training: %s', s)
+ end
trainer:train(dataset)
local out = torch.MemoryFile()
out:writeObject(rule.anns[elt].ann_train)