aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2020-08-27 15:06:02 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2020-08-27 15:06:02 +0100
commit0641629ce8f6ce9f348b4353c3fc8ce667d15566 (patch)
treec7839c8a7154bf5d31c52b5cb9d142913e997139
parent2c671761a7a88321b321d2a8d7288f65466b2eb3 (diff)
downloadrspamd-0641629ce8f6ce9f348b4353c3fc8ce667d15566.tar.gz
rspamd-0641629ce8f6ce9f348b4353c3fc8ce667d15566.zip
[Project] Neural: Start PCA implementation
-rw-r--r--src/plugins/lua/neural.lua10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/plugins/lua/neural.lua b/src/plugins/lua/neural.lua
index 9df2f1c55..a3027662c 100644
--- a/src/plugins/lua/neural.lua
+++ b/src/plugins/lua/neural.lua
@@ -24,6 +24,7 @@ local rspamd_util = require "rspamd_util"
local rspamd_kann = require "rspamd_kann"
local lua_redis = require "lua_redis"
local lua_util = require "lua_util"
+local rspamd_tensor = require "rspamd_tensor"
local fun = require "fun"
local lua_settings = require "lua_settings"
local meta_functions = require "lua_meta"
@@ -58,6 +59,7 @@ local default_options = {
hidden_layer_mult = 1.5, -- number of neurons in the hidden layer
symbol_spam = 'NEURAL_SPAM',
symbol_ham = 'NEURAL_HAM',
+ max_inputs = nil, -- when PCA is used
}
local redis_profile_schema = ts.shape{
@@ -68,6 +70,8 @@ local redis_profile_schema = ts.shape{
distance = ts.number:is_optional(),
}
+local has_blas = rspamd_tensor.has_blas()
+
-- Rule structure:
-- * static config fields (see `default_options`)
-- * prefix - name or defined prefix
@@ -1488,6 +1492,12 @@ for k,r in pairs(rules) do
if not rule_elt.profile then rule_elt.profile = {} end
+ if rule_elt.max_inputs and not has_blas then
+ rspamd_logger.errx('cannot set max inputs to %s as BLAS is not compiled in',
+ rule_elt.name, rule_elt.max_inputs)
+ rule_elt.max_inputs = nil
+ end
+
rspamd_logger.infox(rspamd_config, "register ann rule %s", k)
settings.rules[k] = rule_elt
rspamd_config:set_metric_symbol({