Python lasagne.updates 模块,sgd() 实例源码

我们从Python开源项目中,提取了以下2个代码示例,用于说明如何使用lasagne.updates.sgd()

项目:Synkhronos    作者:astooke    | 项目源码 | 文件源码
def build_train_func(rank=0, **kwargs):
    print("rank: {} Building model".format(rank))
    resnet = build_resnet()

    print("Building training function")
    x = T.ftensor4('x')
    y = T.imatrix('y')

    prob = L.get_output(resnet['prob'], x, deterministic=False)
    loss = T.nnet.categorical_crossentropy(prob, y.flatten()).mean()
    params = L.get_all_params(resnet.values(), trainable=True)

    sgd_updates = updates.sgd(loss, params, learning_rate=1e-4)

    # make a function to compute and store the raw gradient
    f_train = theano.function(inputs=[x, y],
                              outputs=loss,  # (assumes this is an avg)
                              updates=sgd_updates)

    return f_train, "original"
项目:crayimage    作者:yandexdataschool    | 项目源码 | 文件源码
def optimizer(self, params, learning_rate):
    return updates.sgd(self.loss, params, learning_rate)