Beispiel #1
0
            public static IColumnFunctionBuilder CreateBuilder(MinMaxArguments args, IHost host,
                                                               int icol, int srcIndex, ColumnType srcType, IRowCursor cursor)
            {
                Contracts.AssertValue(host);
                host.AssertValue(args);

                if (srcType.IsNumber)
                {
                    if (srcType == NumberType.R4)
                    {
                        return(Sng.MinMaxOneColumnFunctionBuilder.Create(args, host, icol, srcType, cursor.GetGetter <Single>(srcIndex)));
                    }
                    if (srcType == NumberType.R8)
                    {
                        return(Dbl.MinMaxOneColumnFunctionBuilder.Create(args, host, icol, srcType, cursor.GetGetter <Double>(srcIndex)));
                    }
                }
                if (srcType.IsVector && srcType.ItemType.IsNumber)
                {
                    if (srcType.ItemType == NumberType.R4)
                    {
                        return(Sng.MinMaxVecColumnFunctionBuilder.Create(args, host, icol, srcType, cursor.GetGetter <VBuffer <Single> >(srcIndex)));
                    }
                    if (srcType.ItemType == NumberType.R8)
                    {
                        return(Dbl.MinMaxVecColumnFunctionBuilder.Create(args, host, icol, srcType, cursor.GetGetter <VBuffer <Double> >(srcIndex)));
                    }
                }
                throw host.ExceptUserArg(nameof(args.Column), "Wrong column type for column {0}. Expected: R4, R8, Vec<R4, n> or Vec<R8, n>. Got: {1}.", args.Column[icol].Source, srcType.ToString());
            }
Beispiel #2
0
        /// <summary>
        /// Public create method corresponding to SignatureDataTransform.
        /// </summary>
        public static NormalizeTransform Create(IHostEnvironment env, MinMaxArguments args, IDataView input)
        {
            Contracts.CheckValue(env, nameof(env));
            var h = env.Register("Normalize(MinMax)");
            NormalizeTransform func;

            using (var ch = h.Start("Training"))
            {
                func = Create(h, args, input, MinMaxUtils.CreateBuilder);
                ch.Done();
            }
            return(func);
        }