示例#1
0
        double validation_phase(CNTK.MinibatchSource reader)
        {
            var featuresStreamInfo = reader.StreamInfo("features");
            var labelsStreamInfo   = reader.StreamInfo("labels");
            var num_samples        = 0;
            var num_minibatches    = 0;
            var score = 0.0;

            while (num_samples < 2 * validation_set_size)
            {
                num_minibatches++;
                var minibatchData = reader.GetNextMinibatch(minibatch_size, computeDevice);
                var arguments     = new test_feed_t {
                    { features_tensor, minibatchData[featuresStreamInfo] }, { label_tensor, minibatchData[labelsStreamInfo] }
                };
                num_samples += (int)(minibatchData[featuresStreamInfo].numberOfSamples);
                evaluator.TestMinibatch(arguments, computeDevice);
                score += trainer.PreviousMinibatchEvaluationAverage();
            }
            var result = 1.0 - (score / num_minibatches);

            return(result);
        }
示例#2
0
 /// <summary>
 /// Get a batch from the given image reader.
 /// </summary>
 /// <param name="reader">The image reader to use.</param>
 /// <param name="batchSize">The size of the batch.</param>
 /// <returns>A batch of values taken from the given image reader.</returns>
 public static CNTK.UnorderedMapStreamInformationMinibatchData GetBatch(
     this CNTK.MinibatchSource reader,
     int batchSize)
 {
     return(reader.GetNextMinibatch((uint)batchSize, NetUtil.CurrentDevice));
 }