commit 0641629: [Project] Neural: Start PCA implementation

Vsevolod Stakhov vsevolod at highsecure.ru
Thu Aug 27 21:49:06 UTC 2020


Author: Vsevolod Stakhov
Date: 2020-08-27 15:06:02 +0100
URL: https://github.com/rspamd/rspamd/commit/0641629ce8f6ce9f348b4353c3fc8ce667d15566

[Project] Neural: Start PCA implementation

---
 src/plugins/lua/neural.lua | 10 ++++++++++
 1 file changed, 10 insertions(+)

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({


More information about the Commits mailing list