model.py 文件源码

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

项目:deeplearning 作者: wangzhics 项目源码 文件源码
def __init__(self, rng, input, input_shape, filter_shape, pool_shape=(2, 2)):
        """
        ???????????????????????
        :param input: ?????
        :param input_shape: ????????(batch_size, image_channel, image_weight, image_height)
        :param filter_shape: ???????(filter_count, filter_channel, filter_weight, filter_height)
        :param pool_shape: ??????
        :return:
        """
        #
        assert input_shape[1] == filter_shape[1]
        self.input = input
        self.input_shape = input_shape
        self.filter_shape = filter_shape
        self.pool_shape = pool_shape
        # ?????????
        n_in = numpy.prod(input_shape[1:])
        n_out = (filter_shape[0] * numpy.prod(filter_shape[2:]) // numpy.prod(pool_shape))
        weight_max = numpy.sqrt(6. / (n_in + n_out))
        self.w = theano.shared(
            numpy.asarray(
                rng.uniform(low=-weight_max, high=weight_max, size=filter_shape),
                dtype=theano.config.floatX
            ),
            borrow=True
        )
        self.b = theano.shared(numpy.zeros((filter_shape[0],), dtype=theano.config.floatX), borrow=True)
        self.params = [self.w, self.b]
        # calculate the output
        self.conv_out = conv2d(
            input=self.input,
            filters=self.w,
            filter_shape=self.filter_shape,
            image_shape=self.input_shape
        )
        self.pool_out = pool_2d(
            input=self.conv_out,
            ds=pool_shape,
            ignore_border=True
        )
        self.output = T.tanh(self.pool_out + self.b.dimshuffle('x', 0, 'x', 'x'))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号