jeeModels.py 文件源码

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

项目:jointEE-NN 作者: anoperson 项目源码 文件源码
def LeNetConvPoolLayer(inps, feature_map, batch, length, window, dim, prefix, params, names):
    fan_in = window * dim
    fan_out = feature_map * window * dim / (length - window + 1)

    filter_shape = (feature_map, 1, window, dim)
    image_shape = (batch, 1, length, dim)
    pool_size = (length - window + 1, 1)

    #if non_linear=="none" or non_linear=="relu":
    #    conv_W = theano.shared(0.2 * numpy.random.uniform(low=-1.0,high=1.0,\
    #                            size=filter_shape).astype(theano.config.floatX))

    #else:
    #    W_bound = numpy.sqrt(6. / (fan_in + fan_out))
    #    conv_W = theano.shared(numpy.random.uniform(low=-W_bound,high=W_bound,\
    #                            size=filter_shape).astype(theano.config.floatX))

    W_bound = numpy.sqrt(6. / (fan_in + fan_out))
    conv_W = theano.shared(numpy.random.uniform(low=-W_bound,high=W_bound,\
                            size=filter_shape).astype(theano.config.floatX))

    conv_b = theano.shared(numpy.zeros(filter_shape[0], dtype=theano.config.floatX))

    # bundle
    params += [ conv_W, conv_b ]
    names += [ prefix + '_conv_W_' + str(window), prefix + '_conv_b_' + str(window) ]

    conv_out = conv.conv2d(input=inps, filters=conv_W, filter_shape=filter_shape, image_shape=image_shape)


    conv_out_act = T.tanh(conv_out + conv_b.dimshuffle('x', 0, 'x', 'x'))
    conv_output = downsample.max_pool_2d(input=conv_out_act, ds=pool_size, ignore_border=True)

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


问题


面经


文章

微信
公众号

扫码关注公众号