cnn_layers.py 文件源码

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

项目:sentence_classification 作者: zhegan27 项目源码 文件源码
def encoder(tparams, layer0_input, filter_shape, pool_size,
                      prefix='cnn_encoder'):

    """ filter_shape: (number of filters, num input feature maps, filter height,
                        filter width)
        image_shape: (batch_size, num input feature maps, image height, image width)
    """

    conv_out = conv.conv2d(input=layer0_input, filters=tparams[_p(prefix,'W')], 
                            filter_shape=filter_shape)

    conv_out_tanh = tensor.tanh(conv_out + tparams[_p(prefix,'b')].dimshuffle('x', 0, 'x', 'x'))
    output = pool.pool_2d(input=conv_out_tanh, ds=pool_size, ignore_border=True)

    return output.flatten(2)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号