LayerHelper.py 文件源码

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

项目:LFDL 作者: ffun 项目源码 文件源码
def conv2d(self, x, w_shape, strides, padding, name, reuse=False,
        initializer_w=tf.truncated_normal_initializer(mean=0.0, stddev=1e-2),
        initializer_b=tf.truncated_normal_initializer(mean=0.0, stddev=1e-2)
        ):
        '''
        convolution layer:
        Input
        - x:input tensor
        - w_shape:weight shape for convolution kernel
        - strides
        - padding:'SAME' or 'VALID'
        - name:variable name scope
        - initializer_w/b:initializer of weight and bias
        '''
        _, _, _, num_out = w_shape
        with tf.variable_scope(name, reuse=reuse) as scope:
            weights = tf.get_variable('weights', w_shape, initializer=initializer_w)
            biases = tf.get_variable('biases', [num_out], initializer=initializer_b)
        #conv
        conv = tf.nn.conv2d(x, weights, strides, padding)
        #relu
        relu = tf.nn.relu(conv + biases, name=scope.name)
        return relu
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号