示例#1
0
        public override bool Equals(object obj)
        {
            if (this == obj)
            {
                return(true);
            }
            if (obj == null)
            {
                return(false);
            }
            if (!(obj is EncoderResult))
            {
                return(false);
            }
            EncoderResult other = (EncoderResult)obj;

            if (!this.GetScalar().Equals(other.GetScalar()))
            {
                return(false);
            }
            if (!this.GetValue().Equals(other.GetValue()))
            {
                return(false);
            }
            if (!Arrays.AreEqual(this.GetEncoding(), other.GetEncoding()))
            {
                return(false);
            }
            return(true);
        }
示例#2
0
        /**
         * {@inheritDoc}
         */
        public override List <EncoderResult> TopDownCompute(int[] encoded)
        {
            EncoderResult scaledResult = _encoder.TopDownCompute(encoded)[0];
            double        scaledValue  = (double)scaledResult.GetValue();
            double        value        = Math.Pow(10, scaledValue);

            return(new List <EncoderResult> {
                new EncoderResult(value, value, scaledResult.GetEncoding())
            });
        }
示例#3
0
        /**
         * {@inheritDoc}
         */
        public override List <EncoderResult> GetBucketInfo(int[] buckets)
        {
            EncoderResult scaledResult = _encoder.GetBucketInfo(buckets)[0];
            double        scaledValue  = (double)scaledResult.GetValue();
            double        value        = Math.Pow(10, scaledValue);

            return(new List <EncoderResult> {
                new EncoderResult(value, value, scaledResult.GetEncoding())
            });
        }
示例#4
0
        /**
         * {@inheritDoc}
         */
        public override List <EncoderResult> GetBucketInfo(int[] buckets)
        {
            // For the category encoder, the bucket index is the category index
            List <EncoderResult> bucketInfo = scalarEncoder.GetBucketInfo(buckets);

            int    categoryIndex = (int)Math.Round((double)bucketInfo[0].GetValue());
            string category      = indexToCategory[categoryIndex];

            bucketInfo[0] = new EncoderResult(category, categoryIndex, bucketInfo[0].GetEncoding());
            return(bucketInfo);
        }
示例#5
0
 /**
  * {@inheritDoc}
  */
 public override List <EncoderResult> GetBucketInfo(int[] buckets)
 {
     if (this.minVal == 0 || this.maxVal == 0)
     {
         int[] initialBuckets = new int[this.n];
         Arrays.Fill(initialBuckets, 0);
         List <EncoderResult> encoderResultList = new List <EncoderResult>();
         EncoderResult        encoderResult     = new EncoderResult(0, 0, initialBuckets);
         encoderResultList.Add(encoderResult);
         return(encoderResultList);
     }
     return(base.GetBucketInfo(buckets));
 }
示例#6
0
 /**
  * {@inheritDoc}
  */
 public override List <EncoderResult> TopDownCompute(int[] encoded)
 {
     if (this.GetMinVal() == 0 || this.GetMaxVal() == 0)
     {
         List <EncoderResult> res = new List <EncoderResult>();
         int[] enArray            = new int[this.GetN()];
         Arrays.Fill(enArray, 0);
         EncoderResult ecResult = new EncoderResult(0, 0, enArray);
         res.Add(ecResult);
         return(res);
     }
     return(base.TopDownCompute(encoded));
 }
示例#7
0
        /**
         * {@inheritDoc}
         * @see org.numenta.nupic.encoders.AdaptiveScalarEncoder#topDownCompute(int[])
         */

        public override List <EncoderResult> TopDownCompute(int[] encoded)
        {
            if (this.PrevAbsolute == 0 || this.PrevDelta == 0)
            {
                int[] initialBuckets = new int[this.n];
                Arrays.Fill(initialBuckets, 0);
                List <EncoderResult> encoderResultList = new List <EncoderResult>();
                EncoderResult        encoderResult     = new EncoderResult(0, 0, initialBuckets);
                encoderResultList.Add(encoderResult);
                return(encoderResultList);
            }
            List <EncoderResult> erList = base.TopDownCompute(encoded);

            if (this.PrevAbsolute != 0)
            {
                double objVal    = (double)(erList[0].GetValue()) + this.PrevAbsolute;
                double objScalar = erList[0].GetScalar() + this.PrevAbsolute;
                List <EncoderResult> encoderResultList = new List <EncoderResult>();
                EncoderResult        encoderResult     = new EncoderResult(objVal, objScalar, erList[0].GetEncoding());
                encoderResultList.Add(encoderResult);
                return(encoderResultList);
            }
            return(erList);
        }