Skip to content

Instantly share code, notes, and snippets.

@keskarnitish
keskarnitish / cg.py
Created March 14, 2016 16:48 — forked from CarlosCancino-Chacon/cg.py
Conjugate gradient optimization for Lasagne
from collections import OrderedDict
import numpy as np
import theano
import theano.tensor as T
from theano.ifelse import ifelse
def cg(loss, params, x0=None, max_iters=100, precondition=None, tol=1e-3,
conv_crit='cg'):
"""(Preconditioned) Conjugate Gradient (CG) updates