protected SlidingWindowTransformBase(Arguments args, string loaderSignature, IHostEnvironment env, IDataView input)
     : base(args.WindowSize + args.Lag - 1, args.WindowSize + args.Lag - 1, args.Name, args.Source, loaderSignature, env, input)
 {
     Host.CheckUserArg(args.WindowSize >= 1, nameof(args.WindowSize), "Must be at least 1.");
     Host.CheckUserArg(args.Lag >= 0, nameof(args.Lag), "Must be positive.");
     if (args.Lag == 0 && args.WindowSize <= 1)
     {
         Host.Assert(args.WindowSize == 1);
         throw Host.ExceptUserArg(nameof(args.Lag),
                                  $"If {args.Lag}=0 and {args.WindowSize}=1, the transform just copies the column. Use {ColumnCopyingTransformer.LoaderSignature} transform instead.");
     }
     Host.CheckUserArg(Enum.IsDefined(typeof(BeginOptions), args.Begin), nameof(args.Begin), "Undefined value.");
     _lag      = args.Lag;
     _begin    = args.Begin;
     _nanValue = GetNaValue();
 }
Ejemplo n.º 2
0
        protected SlidingWindowTransformBase(IHostEnvironment env, ModelLoadContext ctx, string loaderSignature, IDataView input)
            : base(env, ctx, loaderSignature, input)
        {
            // *** Binary format ***
            // <base>
            // Int32 lag
            // byte begin

            Host.CheckDecode(WindowSize >= 1);
            _lag = ctx.Reader.ReadInt32();
            Host.CheckDecode(_lag >= 0);
            byte r = ctx.Reader.ReadByte();
            Host.CheckDecode(Enum.IsDefined(typeof(BeginOptions), r));
            _begin = (BeginOptions)r;
            _nanValue = GetNaValue();
        }