Loading TOC...


   $weights as cntk.variable,
   $num-samples as (Number|String),
   $allow-duplicates as Boolean,
   [$seed as (Number|String)],
   [$name as String]
) as cntk.function


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.

$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.


  var inputVariable1 = cntk.inputVariable(cntk.shape([3]), "float", fn.false(),
    fn.false(), "feature")
  cntk.randomSample(inputVariable1, 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.