private OvaPredictor(IHostEnvironment env, ModelLoadContext ctx) : base(env, RegistrationName, ctx) { // *** Binary format *** // bool: useDist // int: predictor count bool useDist = ctx.Reader.ReadBoolByte(); int len = ctx.Reader.ReadInt32(); Host.CheckDecode(len > 0); if (useDist) { var predictors = new IValueMapperDist[len]; LoadPredictors(Host, predictors, ctx); _impl = new ImplDist(predictors); } else { var predictors = new TScalarPredictor[len]; LoadPredictors(Host, predictors, ctx); _impl = new ImplRaw(predictors); } OutputType = new VectorType(NumberType.Float, _impl.Predictors.Length); }
private OneVersusAllModelParameters(IHostEnvironment env, ModelLoadContext ctx) : base(env, RegistrationName, ctx) { // *** Binary format *** // byte: OutputFormula as byte // int: predictor count OutputFormula outputFormula = (OutputFormula)ctx.Reader.ReadByte(); int len = ctx.Reader.ReadInt32(); Host.CheckDecode(len > 0); if (outputFormula == OutputFormula.Raw) { var predictors = new TScalarPredictor[len]; LoadPredictors(Host, predictors, ctx); _impl = new ImplRaw(predictors); } else if (outputFormula == OutputFormula.ProbabilityNormalization) { var predictors = new IValueMapperDist[len]; LoadPredictors(Host, predictors, ctx); _impl = new ImplDist(predictors); } else if (outputFormula == OutputFormula.Softmax) { var predictors = new TScalarPredictor[len]; LoadPredictors(Host, predictors, ctx); _impl = new ImplSoftmax(predictors); } DistType = new VectorDataViewType(NumberDataViewType.Single, _impl.Predictors.Length); }
private OptimizedOVAPredictor(IHostEnvironment env, ImplBase impl) : base(env, RegistrationName) { Host.AssertValue(impl, "impl"); Host.Assert(Utils.Size(impl.Predictors) > 0); _impl = impl; _outputType = new VectorDataViewType(NumberDataViewType.Single, _impl.Predictors.Length); }
private OvaPredictor(IHostEnvironment env, ImplBase impl) : base(env, RegistrationName) { Host.AssertValue(impl, nameof(impl)); Host.Assert(Utils.Size(impl.Predictors) > 0); _impl = impl; OutputType = new VectorType(NumberType.Float, _impl.Predictors.Length); }
private OneVersusAllModelParameters(IHostEnvironment env, ImplBase impl) : base(env, RegistrationName) { Host.AssertValue(impl, nameof(impl)); Host.Assert(Utils.Size(impl.Predictors) > 0); _impl = impl; DistType = new VectorDataViewType(NumberDataViewType.Single, _impl.Predictors.Length); }
protected ImplBase(ImplBase <TOptions> impl, string name) { Contracts.CheckValue(impl, nameof(impl)); Contracts.AssertValue(impl.Host); impl.Host.AssertValue(impl.ImplOptions); impl.Host.AssertValue(name); ImplOptions = impl.ImplOptions; Host = impl.Host.Register(name); }
protected ImplBase(ImplBase <TArgs> impl, string name) { Contracts.CheckValue(impl, nameof(impl)); Contracts.AssertValue(impl.Host); impl.Host.AssertValue(impl.Args); impl.Host.AssertValue(name); Args = impl.Args; Host = impl.Host.Register(name); }
/// <summary>Constructor used by <see cref="ThreadSafeRandom"/>.</summary> /// <param name="isThreadSafeRandom">Must be true.</param> protected private Random(bool isThreadSafeRandom) { Debug.Assert(isThreadSafeRandom); _impl = null !; // base implementation isn't used at all }