Beispiel #1
0
        public int GetValue(Digit digit)
        {
            var imap = new Dictionary <Variable, Value> {
                { mFeatures, Value.CreateBatch <float>(new int[] { INPUT_DIMENSION }, digit.Image, device) }
            };
            var omap = new Dictionary <Variable, Value> {
                { mFunction, null }
            };

            mFunction.Evaluate(imap, omap, device);
            var result = omap[mFunction].GetDenseData <float>(mFunction).First();

            return(result.IndexOf(result.Max()));
        }
Beispiel #2
0
        private void GenerateRawDataSamples(int sampleSize, int inputDim, int numOutputClasses,
                                            out float[] features, out float[] oneHotLabels)
        {
            features     = new float[sampleSize * inputDim];
            oneHotLabels = new float[sampleSize * numOutputClasses];

            for (int sample = 0; sample < sampleSize; sample++)
            {
                Digit digt = mDigits[(mCurrentTest++) % mDigits.Length];

                for (int i = 0; i < numOutputClasses; i++)
                {
                    oneHotLabels[sample * numOutputClasses + i] = (digt.Label == i) ? 1 : 0;
                }

                for (int i = 0; i < inputDim; i++)
                {
                    features[sample * inputDim + i] = digt.Image[i];
                }
            }
        }