public void PostConfigure(string name, ModelPredictionEngineOptions <TData, TPrediction> options)
        {
            _options = options;

            if (_logger.IsEnabled(options.LogLevel))
            {
                options.MLContext().Log += Log;
            }
        }
예제 #2
0
 public ModelPredictionEnginePooledObjectPolicy(
     MLContext mlContext,
     ITransformer model,
     ModelPredictionEngineOptions <TData, TPrediction> options,
     ILogger logger)
 {
     _mlContext = mlContext ?? throw new ArgumentNullException(nameof(mlContext));
     _model     = model ?? throw new ArgumentNullException(nameof(model));
     _logger    = logger ?? throw new ArgumentNullException(nameof(logger));
     _options   = options ?? throw new ArgumentNullException(nameof(options));
 }
예제 #3
0
        public ModelPoolLoader(ModelPredictionEngineOptions <TInput, TPrediction> options)
        {
            _options = options ?? throw new ArgumentNullException(nameof(options));

            _mlContext = _options.ServiceProvider.GetRequiredService <IOptions <MLContextOptions> >().Value.MLContext
                         ?? throw new NullReferenceException("MLContext instance is missing");

            _logger = _options.ServiceProvider.GetRequiredService <ILoggerFactory>().CreateLogger(nameof(ModelPoolLoader <TInput, TPrediction>));

            LoadPool();

            _changeToken = ChangeToken.OnChange(
                () => _options.GetReloadToken(),
                () => LoadPool());
        }
예제 #4
0
        public ModelPredictionEngineObjectPool(
            Func <ModelPredictionEngineOptions <TData, TPrediction> > options,
            ILoggerFactory loggerFactory)
        {
            _funcOptions = options ?? throw new ArgumentNullException(nameof(options));

            _logger = loggerFactory.CreateLogger(nameof(ModelPredictionEngineObjectPool <TData, TPrediction>))
                      ?? throw new ArgumentNullException(nameof(loggerFactory));

            _options = _funcOptions();

            LoadPool();

            _changeToken = ChangeToken.OnChange(
                () => _options.GetReloadToken(),
                () => LoadPool());
        }
예제 #5
0
        public ModelPredictionEngineObjectPool(
            Func <ModelPredictionEngineOptions <TData, TPrediction> > options,
            ILoggerFactory loggerFactory)
        {
            _options = options() ?? throw new ArgumentNullException(nameof(options));

            _logger = loggerFactory.CreateLogger(nameof(ModelPredictionEngineObjectPool <TData, TPrediction>))
                      ?? throw new ArgumentNullException(nameof(loggerFactory));

            // get mlcontext
            _mlContext = _options.MLContext();

            // get prediction model
            Model = _options.CreateModel(_mlContext);

            // create PredictionEngine Object Pool
            _predictionEnginePool = CreatePredictionEngineObjectPool();
        }
 public void Configure(ModelPredictionEngineOptions <TData, TPrediction> options)
 {
     Configure(options.ModelName, options);
 }
 public void Configure(string name, ModelPredictionEngineOptions <TData, TPrediction> options)
 {
     options.ModelName       = name;
     options.ServiceProvider = _serviceProvider;
 }
예제 #8
0
 public void Configure(string name, ModelPredictionEngineOptions <TData, TPrediction> options)
 {
     options.ModelName = name;
 }