get_sampling_probability

opennmt.decoders.get_sampling_probability(step, read_probability=None, schedule_type=None, k=None)[source]

Returns the sampling probability as described in https://arxiv.org/abs/1506.03099.

Parameters
  • step – The training step.

  • read_probability – The probability to read from the inputs.

  • schedule_type – The type of schedule: “constant”, “linear”, “exponential”, or “inverse_sigmoid”.

  • k – The convergence constant.

Returns

The probability to sample from the output ids as a 0D tf.Tensor or None if scheduled sampling is not configured.

Raises
  • ValueError – if schedule_type is set but not k or if schedule_type is linear but an initial read_probability is not set.

  • TypeError – if schedule_type is invalid.