ops.py 文件源码

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

项目:WaveNet 作者: ritheshkumar95 项目源码 文件源码
def GRUStep(name, input_dim, hidden_dim, x_t, h_tm1):
    processed_input = lib.ops.Dense(
        name+'.Input',
        input_dim,
        3 * hidden_dim,
        x_t
    )

    gates = T.nnet.sigmoid(
        lib.ops.Dense(
            name+'.Recurrent_Gates',
            hidden_dim,
            2 * hidden_dim,
            h_tm1,
            bias=False
        ) + processed_input[:, :2*hidden_dim]
    )

    update = gates[:, :hidden_dim]
    reset  = gates[:, hidden_dim:]

    scaled_hidden = reset * h_tm1

    candidate = T.tanh(
        lib.ops.Dense(
            name+'.Recurrent_Candidate',
            hidden_dim,
            hidden_dim,
            scaled_hidden,
            bias=False,
            init='orthogonal'
        ) + processed_input[:, 2*hidden_dim:]
    )

    one = lib.floatX(1.0)
    return (update * candidate) + ((one - update) * h_tm1)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号