(
    num_updates,
    e_step,
    m_step,
    variables,
)
return updated_vars
Expectation-maximization of objective_fn wrt variables for num_updates.
Expectation-maximization of objective_fn wrt variables for num_updates.
Expectation - maximization of objective_fn wrt variables for num_updates .
def em_loop(
    num_updates,
    e_step,
    m_step,
    variables,
):
  """Expectation-maximization of objective_fn wrt variables for num_updates."""

  def _body(step, preupdate_vars):
    train_predictions_, responsibilities_ = e_step(preupdate_vars)
    updated_vars = m_step(preupdate_vars, train_predictions_, responsibilities_)
    return step + 1, updated_vars

  def _cond(step, *args):
    del args
    return step < num_updates

  step = tf.Variable(0, trainable=False, name='inner_step_counter')
  loop_vars = (step, variables)
  step, updated_vars = tf.while_loop(
      cond=_cond, body=_body, loop_vars=loop_vars, swap_memory=True)

  return updated_vars
def em_loop ( num_updates , e_step , m_step , variables , ) : def _body ( step , preupdate_vars ) : train_predictions_ , responsibilities_ = e_step ( preupdate_vars ) updated_vars = m_step ( preupdate_vars , train_predictions_ , responsibilities_ ) return step + 1 , updated_vars def _cond ( step , * args ) : del args return step < num_updates step = tf . Variable ( 0 , trainable = False , name = 'inner_step_counter' ) loop_vars = ( step , variables ) step , updated_vars = tf . while_loop ( cond = _cond , body = _body , loop_vars = loop_vars , swap_memory = True ) return updated_vars