Beispiel #1
0
def _watch_with_tape_vjp(g, ans, vs, gvs, tape, tensor):
  """Gradient for _watch_with_tape_internal."""
  del ans, gvs, tape

  def mut_add(implicit_tape):
    t = ag_core.getval(tensor)
    implicit_tape.gradients.append((t, g))
    return implicit_tape

  return ag_core.SparseObject(vs, mut_add)
Beispiel #2
0
def _watch_with_tape_vjp(g, ans, vs, gvs, tape, tensor):
    """Gradient for _watch_with_tape_internal."""
    del ans, gvs

    def mut_add(implicit_tape):
        resource_variable = tape.value.variables[ops.tensor_id(tensor)]
        implicit_tape.gradients.append((g, resource_variable))
        return implicit_tape

    return ag_core.SparseObject(vs, mut_add)