示例#1
0
        /**
         * Open up for internal Network API use.
         * Returns an {@link Encoder.Builder} which corresponds to the specified name.
         * @param encoderName
         * @return
         */
        public IBuilder GetBuilder(string encoderName)
        {
            switch (encoderName)
            {
            case "CategoryEncoder":
                return(CategoryEncoder.GetBuilder());

            case "CoordinateEncoder":
                return(CoordinateEncoder.GetBuilder());

            case "GeospatialCoordinateEncoder":
                return(GeospatialCoordinateEncoder.GetGeobuilder());

            case "LogEncoder":
                return(LogEncoder.GetBuilder());

            case "PassThroughEncoder":
                return(PassThroughEncoder <int[]> .GetBuilder());

            case "ScalarEncoder":
                return(ScalarEncoder.GetBuilder());

            case "AdaptiveScalarEncoder":
                return(AdaptiveScalarEncoder.GetAdaptiveBuilder());

            case "SparsePassThroughEncoder":
                return(SparsePassThroughEncoder.GetSparseBuilder());

            case "SDRCategoryEncoder":
                return(SDRCategoryEncoder.GetBuilder());

            case "RandomDistributedScalarEncoder":
                return(RandomDistributedScalarEncoder.GetBuilder());

            case "DateEncoder":
                return(DateEncoder.GetBuilder());

            case "DeltaEncoder":
                return(DeltaEncoder.GetDeltaBuilder());

            case "SDRPassThroughEncoder":
                return(SDRPassThroughEncoder.GetSptBuilder());

            default:
                throw new ArgumentException("Invalid encoder: " + encoderName);
            }
        }
示例#2
0
            public override IEncoder Build()
            {
                //Must be instantiated so that super class can initialize
                //boilerplate variables.
                encoder = new GeospatialCoordinateEncoder();

                //Call super class here
                base.Build();

                ////////////////////////////////////////////////////////
                //  Implementing classes would do setting of specific //
                //  vars here together with any sanity checking       //
                ////////////////////////////////////////////////////////
                if (_scale == 0 || _timestep == 0)
                {
                    throw new InvalidOperationException("Scale or Timestep not set");
                }

                ((GeospatialCoordinateEncoder)encoder)._scale    = _scale;
                ((GeospatialCoordinateEncoder)encoder)._timestep = _timestep;

                if (w <= 0 || w % 2 == 0)
                {
                    throw new ArgumentException("w must be odd, and must be a positive integer");
                }

                if (n <= 6 * w)
                {
                    throw new ArgumentException(
                              "n must be an int strictly greater than 6*w. For " +
                              "good results we recommend n be strictly greater than 11*w");
                }

                if (name == null || name.Equals("None"))
                {
                    name = new StringBuilder("[").Append(n).Append(":").Append(w).Append("]").ToString();
                }

                return((GeospatialCoordinateEncoder)encoder);
            }