network.py 文件源码

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

项目:python-machine-learning 作者: sho-87 项目源码 文件源码
def __init__(self, filter_shape, image_shape, border_mode='half',
                 stride=(1, 1), activation_fn=sigmoid):
        """`filter_shape` is a tuple of length 4, whose entries are the number
        of filters, the number of input feature maps, the filter height, and
        the filter width.

        `image_shape` is a tuple of length 4, whose entries are the
        mini-batch size, the number of input feature maps, the image
        height, and the image width.

        """
        self.filter_shape = filter_shape
        self.image_shape = image_shape
        self.border_mode = border_mode
        self.stride = stride
        self.activation_fn = activation_fn

        # initialize weights and biases
        n_in = np.prod(filter_shape[1:])  # Total number of input params
        # n_out = (filter_shape[0]*np.prod(filter_shape[2:])/np.prod(poolsize))
        self.w = theano.shared(
            np.asarray(
                np.random.normal(loc=0, scale=np.sqrt(1.0/n_in), size=filter_shape),
                dtype=theano.config.floatX),
            borrow=True)
        self.b = theano.shared(
            np.asarray(
                np.random.normal(loc=0, scale=1.0, size=(filter_shape[0],)),
                dtype=theano.config.floatX),
            borrow=True)
        self.params = [self.w, self.b]
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号