<s> import theano . tensor as _T <EOL> import theano as _th <EOL> class Optimizer : <EOL> def __init__ ( self , ** hyperparams ) : <EOL> self . states = { } <EOL> self . hyperparams = hyperparams <EOL> def update_parameters ( self , model ) : <EOL> if model not in self . states : <EOL> params , grads = model . parameters ( ) <EOL> hyperparams = { name : _T . scalar ( name ) for name in self . hyperparams } <EOL> updates = self . get_updates ( params , grads , ** hyperparams ) <EOL> self . states [ model ] = _th . function ( <EOL> inputs = list ( hyperparams . values ( ) ) , <EOL> updates = updates <EOL> ) <EOL> self . states [ model ] ( ** self . hyperparams ) <EOL> def get_updates ( self , params , grads ) : <EOL> raise NotImplementedError </s>
