Browse Source

[Project] Neural: Start PCA implementation

tags/2.6
Vsevolod Stakhov 3 years ago
parent
commit
0641629ce8
1 changed files with 10 additions and 0 deletions
  1. 10
    0
      src/plugins/lua/neural.lua

+ 10
- 0
src/plugins/lua/neural.lua View File

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

Loading…
Cancel
Save