
import theano.tensor as T
import theano

# Compile objective function defined in Theano.
def compile(objective, argument):
    return theano.function([argument], objective)

# Compute the gradient of 'objective' with respect to 'argument' and return
# compiled function.
def gradient(objective, argument):
    g = T.grad(objective, argument)
    return theano.function([argument], g)

import theano.tensor as T
import theano

# Compile objective function defined in Theano.
def compile(objective, argument):
    return theano.function([argument], objective)

# Compute the gradient of 'objective' with respect to 'argument' and return
# compiled function.
def gradient(objective, argument):
    g = T.grad(objective, argument)
    return compile(g, argument)


Use `compile` function for `gradient` function
Use `compile` function for `gradient` function

Signed-off-by: Niklas Koep <342d5290239d9c5264c8f98185afedb99596601a@gmail.com>

  
  import theano.tensor as T
  import theano
  
  # Compile objective function defined in Theano.
  def compile(objective, argument):
      return theano.function([argument], objective)
  
  # Compute the gradient of 'objective' with respect to 'argument' and return
  # compiled function.
  def gradient(objective, argument):
      g = T.grad(objective, argument)
-     return theano.function([argument], g)
+     return compile(g, argument)
+ 
+ 
Use `compile` function for `gradient` function
## Code Before:

import theano.tensor as T
import theano

# Compile objective function defined in Theano.
def compile(objective, argument):
    return theano.function([argument], objective)

# Compute the gradient of 'objective' with respect to 'argument' and return
# compiled function.
def gradient(objective, argument):
    g = T.grad(objective, argument)
    return theano.function([argument], g)
## Instruction:
Use `compile` function for `gradient` function
## Code After:

import theano.tensor as T
import theano

# Compile objective function defined in Theano.
def compile(objective, argument):
    return theano.function([argument], objective)

# Compute the gradient of 'objective' with respect to 'argument' and return
# compiled function.
def gradient(objective, argument):
    g = T.grad(objective, argument)
    return compile(g, argument)

