Loading TOC...

cntk:total-number-of-sample-seen

cntk:total-number-of-sample-seen(
   $trainer as cntk:trainer
) as xs:unsignedLong

Summary

The total number of samples seen by this trainer.

Parameters
$trainer The input trainer.

Example

xquery version "1.0-ml";

let $input-dims := 2
let $num-classes := 2

let $input-variable := cntk:input-variable(cntk:shape(($input-dims)), "float", fn:false(), fn:false(), "feature")
let $training-data := json:to-array((2.2,3.5,5.1,5.7,1.3,5.5,3.5,2.4))
let $input-value := cntk:batch(cntk:shape(($input-dims)), $training-data, cntk:cpu(), "float")

let $labels-variable := cntk:input-variable(cntk:shape(($num-classes)), "float", fn:false(), fn:false(), "labels")
let $labels := json:to-array((1,0,0,1,0,1,1,0))
let $labels-value := cntk:batch(cntk:shape(($num-classes)), $labels, cntk:cpu(), "float")

let $W := cntk:parameter(cntk:shape(($input-dims)), "float", cntk:glorot-uniform-initializer(), cntk:cpu(), "parameter")
let $model := cntk:times($input-variable, $W, 1, -1)
let $learner := cntk:sgd-learner(($W), cntk:learning-rate-schedule-from-constant(0.01), 
                map:map() => map:with("l1-regularization-weight", 0.1)
                          => map:with("l2-regularization-weight", 0.2)
                          => map:with("gaussian-noise-injection-std-dev", cntk:learning-rate-schedule-from-constant(0.01, 100))
                          => map:with("gradient-clipping-threshold-per-sample", 0.3)  
                          => map:with("gradient-clipping-with-truncation", fn:false()))
let $loss := cntk:binary-cross-entropy($model, $labels-variable, "loss_func")
let $metric := cntk:classification-error($model, $labels-variable, 1, cntk:axis(-1), "metric")
let $trainer := cntk:trainer($model, ($learner), $loss, $metric)

let $input-pair := json:to-array(($input-variable, $input-value))
let $labels-pair := json:to-array(($labels-variable, $labels-value))
let $minibatch := json:to-array(($input-pair, $labels-pair))
for $i in (1 to 5)
  let $_ := cntk:train-minibatch($trainer, $minibatch, fn:false())
  return ('loss-average: ', xdmp:type(cntk:previous-minibatch-loss-average($trainer)), '
', 
          'evaluation-average: ', cntk:previous-minibatch-evaluation-average($trainer), '
', 
          'sample-count: ', cntk:previous-minibatch-sample-count($trainer), '
',
          'total-sample: ', cntk:total-number-of-sample-seen($trainer), '

'
          )

Stack Overflow iconStack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.