Exemplo n.º 1
0
        public static Transformer <TIn, TOut, TTrans> AssertStatic <[IsShape] TIn, [IsShape] TOut, TTrans>(
            this TTrans transformer, IHostEnvironment env,
            Func <SchemaAssertionContext, TIn> inputDecl,
            Func <SchemaAssertionContext, TOut> outputDecl)
            where TTrans : class, ITransformer
        {
            Contracts.CheckValue(env, nameof(env));
            env.CheckValue(transformer, nameof(transformer));
            env.CheckValue(inputDecl, nameof(inputDecl));
            env.CheckValue(outputDecl, nameof(outputDecl));

            var inSchema  = StaticSchemaShape.Make <TIn>(inputDecl.Method.ReturnParameter);
            var outSchema = StaticSchemaShape.Make <TOut>(outputDecl.Method.ReturnParameter);

            return(new Transformer <TIn, TOut, TTrans>(env, transformer, inSchema, outSchema));
        }
Exemplo n.º 2
0
 internal Estimator(IHostEnvironment env, IEstimator <TTransformer> estimator, StaticSchemaShape inShape, StaticSchemaShape outShape)
     : base(env, outShape)
 {
     Env.CheckValue(estimator, nameof(estimator));
     AsDynamic = estimator;
     _inShape  = inShape;
     // Our ability to check estimators at constructor time is somewaht limited. During fit though we could.
     // Fortunately, estimators are one of the least likely things that users will freqeuently declare the
     // types of on their own.
 }
Exemplo n.º 3
0
 internal Transformer(IHostEnvironment env, TTransformer transformer, StaticSchemaShape inShape, StaticSchemaShape outShape)
     : base(env, outShape)
 {
     Env.AssertValue(transformer);
     Env.AssertValue(inShape);
     AsDynamic = transformer;
     _inShape  = inShape;
     // The ability to check at runtime is limited. We could check during transformation time on the input data view.
 }
Exemplo n.º 4
0
        internal DataReaderEstimator(IHostEnvironment env, IDataReaderEstimator <TIn, TDataReader> estimator, StaticSchemaShape shape)
            : base(env, shape)
        {
            Env.AssertValue(estimator);

            AsDynamic = estimator;
            Shape.Check(Env, AsDynamic.GetOutputSchema());
        }