cnn_model_noBN.py 文件源码

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

项目:SLAM 作者: sanjeevkumar42 项目源码 文件源码
def add_conv_layer(self, scope_name, layer_input, filter_size, input_channels,
                       output_channels, padding='SAME', should_init_wb=True):
        with tf.variable_scope(scope_name):
            weights_shape = filter_size + [input_channels, output_channels]
            initial_weights, initial_bias = self.__get_init_params(scope_name, should_init_wb)
            self.total_weights += weights_shape[0] * weights_shape[1] * weights_shape[2] * weights_shape[3]
            self.logger.info('Weight shape:{} for scope:{}'.format(weights_shape, tf.get_variable_scope().name))
            conv_weights = self.__get_variable('weights', weights_shape, tf.float32,
                                               initializer=initial_weights)

            tf.scalar_summary(scope_name + '/weight_sparsity', tf.nn.zero_fraction(conv_weights))
            tf.histogram_summary(scope_name + '/weights', conv_weights)

            conv = tf.nn.conv2d(layer_input, conv_weights,
                                strides=[1, 1, 1, 1], padding=padding)

            conv_biases = self.__get_variable('biases', [output_channels], tf.float32,
                                                         initializer=initial_bias)

            layer_output = tf.nn.relu(tf.nn.bias_add(conv, conv_biases))

            return layer_output
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号