Beispiel #1
0
def val_and_grad_function(f, params=None):
  """Returns a function that computes f and is derivative w.r.t. params.

  Args:
   f: function to be differentiated.
   params: list of parameter names of f or list of integers indexing the
     parameters with respect to which we'll differentiate. Passing None
     differentiates with respect to all parameters.

  Returns:
   function which, when called, returns the value of f and the
   gradient of f with respect to all of `params`.

  Raises:
   ValueError: if the params are not all strings or all integers.
  """
  return convenience_wrappers.value_and_multigrad(f, _get_arg_spec(f, params))
Beispiel #2
0
def val_and_grad_function(f, params=None):
  """Returns a function that computes f and is derivative w.r.t. params.

  Args:
   f: function to be differentiated.
   params: list of parameter names of f or list of integers indexing the
     parameters with respect to which we'll differentiate. Passing None
     differentiates with respect to all parameters.

  Returns:
   function which, when called, returns the value of f and the
   gradient of f with respect to all of `params`.

  Raises:
   ValueError: if the params are not all strings or all integers.
  """
  return convenience_wrappers.value_and_multigrad(f, _get_arg_spec(f, params))