Loading TOC...

cntk:random-sample

cntk:random-sample(
   $weights as cntk:variable,
   $num-samples as xs:unsignedLong,
   $allow-duplicates as xs:boolean,
   [$seed as xs:unsignedLong],
   [$name as xs:string]
) as cntk:function

Summary

Estimates inclusion frequencies for random sampling with or without replacement. The output value is a set of num_samples random samples represented by a (sparse) matrix of shape [num_samples x len(weights)], where len(weights) is the number of classes (categories) to choose from. The output has no dynamic axis. The samples are drawn according to the weight vector p(i) = weights[i] / sum(weights) We get one set of samples per minibatch. Intended use cases are e.g. sampled softmax, noise contrastive estimation etc.

Parameters
$weights Input vector of sampling weights which should be non-negative numbers.
$num-samples Number of expected samples
$allow-duplicates If sampling is done with replacement (True) or without (False).
$seed Random seed.
$name The name of the function instance in the network.

Example

  let $input-variable1 := cntk:input-variable(cntk:shape((3)), "float",
    fn:false(), fn:false(), "feature")
  return cntk:random-sample($input-variable1, 2, fn:false(), 2, "nQd#]")
  => cntk:function(Composite RandomSample (Input(Name(feature), Shape([3]),
  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.