Exemple #1
0
        private SortInDataFrameTransform(IHost host, ModelLoadContext ctx, IDataView input) : base(host, input)
        {
            Host.CheckValue(input, "input");
            Host.CheckValue(ctx, "ctx");

            _sortColumn = ctx.Reader.ReadString();
            Host.AssertValue(_sortColumn);
            int index;
            var schema = input.Schema;

            if (!schema.TryGetColumnIndex(_sortColumn, out index))
            {
                Contracts.Check(false, "sortColumn not found in input schema.");
            }
            var type = schema.GetColumnType(index);

            Host.Check(!type.IsVector(), "sortColumn cannot be a vector.");
            _reverse    = ctx.Reader.ReadBoolean();
            _numThreads = ctx.Reader.ReadInt32();
            if (_numThreads < 0)
            {
                _numThreads = null;
            }
            _transform = CreateTemplatedTransform();
        }
Exemple #2
0
        public static SortInDataFrameTransform Create(IHostEnvironment env, ModelLoadContext ctx, IDataView input)
        {
            Contracts.CheckValue(env, "env");
            var h = env.Register(RegistrationName);

            h.CheckValue(ctx, "ctx");
            h.CheckValue(input, "input");
            ctx.CheckAtModel(GetVersionInfo());
            return(h.Apply("Loading Model", ch => new SortInDataFrameTransform(h, ctx, input)));
        }
Exemple #3
0
        private ExtendedCacheTransform(IHost host, ModelLoadContext ctx, IDataView input) :
            base(host, input)
        {
            Host.CheckValue(input, "input");
            Host.CheckValue(ctx, "ctx");

            _inDataFrame = ctx.Reader.ReadBoolean();
            _async       = ctx.Reader.ReadBoolean();
            _numThreads  = ctx.Reader.ReadInt32();
            host.Check(_numThreads > -2, "_numThreads");
            if (_numThreads < 0)
            {
                _numThreads = null;
            }
            _saverSettings = ctx.Reader.ReadString();
            if (_inDataFrame)
            {
                _cacheFile = null;
                _reuse     = false;
            }
            else
            {
                _cacheFile = ctx.Reader.ReadString();
                _reuse     = ctx.Reader.ReadBoolean();
                host.CheckValue(_cacheFile, "_cacheFile");
            }

            var saver = ComponentCreation.CreateSaver(Host, _saverSettings);

            if (saver == null)
            {
                throw Host.Except("Cannot parse '{0}'", _saverSettings);
            }

            _pipedTransform = CreatePipeline(host, input);
        }