CAE.py 文件源码

python
阅读 23 收藏 0 点赞 0 评论 0

项目:ConvolutionalAutoEncoder 作者: ToniCreswell 项目源码 文件源码
def prep_train(alpha=0.0002, nz=100):
    E,D=build_net(nz=nz)

    x = T.tensor4('x')

    #Get outputs z=E(x), x_hat=D(z)
    encoding = get_output(E,x)
    decoding = get_output(D,encoding)

    #Get parameters of E and D
    params_e=get_all_params(E, trainable=True)
    params_d=get_all_params(D, trainable=True)
    params = params_e + params_d

    #Calc cost and updates
    cost = T.mean(squared_error(x,decoding))
    grad=T.grad(cost,params)

    updates = adam(grad,params, learning_rate=alpha)

    train = theano.function(inputs=[x], outputs=cost, updates=updates)
    rec = theano.function(inputs=[x], outputs=decoding)
    test = theano.function(inputs=[x], outputs=cost)


    return train ,test, rec, E, D
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号