Loading TOC...

cntk:weighted-binary-cross-entropy

cntk:weighted-binary-cross-entropy(
   $output as cntk:variable,
   $targets as cntk:variable,
   $weights as cntk:variable,
   $name as xs:string
) as cntk:function

Summary

This operation computes the weighted binary cross entropy (aka logistic loss) between the output and target.

Parameters
$output The computed posterior probability from the network.
$targets Ground-truth label, 0 or 1.
$weights Weight of each example.
$name The name of the function instance in the network.

Example

  let $input-variable := cntk:input-variable(cntk:shape((2)), "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((2)), $training-data, cntk:cpu(), "float")

  let $labels-variable := cntk:input-variable(cntk:shape((2)), "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((2)), $labels, cntk:cpu(), "float")

  let $weight-variable := cntk:input-variable(cntk:shape((2)), "float", fn:false(),
    fn:false(), "weight")
  let $weight-data := json:to-array((2,3,5,5,1,5,3,2.4))
  let $weight-value := cntk:batch(cntk:shape((2)), $weight-data, cntk:cpu(), "float")

  let $W := cntk:parameter(cntk:shape((2)), "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.1))
  return cntk:weighted-binary-cross-entropy($model, $labels-variable,
    $weight-variable, "loss_func")
  => cntk:function(Composite Logistic (Input(Name(feature), Shape([2]),
  Dynamic Axes([Sequence Axis(Default Dynamic Axis), Batch Axis(Default Batch Axis)])), Input(Name(labels), Shape([2]), Dynamic Axes([Sequence Axis(Default Dynamic Axis), Batch Axis(Default Batch Axis)])), Input(Name(weight), Shape([2]), Dynamic Axes([Sequence Axis(Default Dynamic Axis), Batch Axis(Default Batch Axis)]))))

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