inception_v1.py 文件源码

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

项目:Deep_Learning_In_Action 作者: SunnyMarkLiu 项目源码 文件源码
def build_inception_v1(self, prediction_fn=tf.nn.relu, scope='InceptionV1'):
        """
        build basic inception v1 model
        """
        # input features [batch_size, height, width, channels]
        self.x = tf.placeholder(tf.float32, shape=[None, 224, 224, 3], name='input_layer')
        self.y = tf.placeholder(tf.float32, [None, self.num_classes], name='output_layer')

        # learning_rate placeholder
        self.learning_rate = tf.placeholder(tf.float32, name='learning_rate')
        # dropout layer: keep probability, vgg default value:0.5
        self.keep_prob = tf.placeholder(tf.float32, name='keep_prob')

        with tf.variable_scope(name_or_scope=scope, reuse=False) as scope:
            net, ent_point_nets = self.inception_v1_base(self.x, scope=scope)
            with tf.variable_scope('Logits'):
                net = slim.avg_pool2d(net, kernel_size=[7, 7], stride=1, scope='MaxPool_0a_7x7')
                net = slim.dropout(net, self.keep_prob, scope='Dropout_0b')
                # translate [1, 1, 1024] -> [1024]
                net = net[:, 0, 0, :]
                self.logits = slim.fully_connected(net, num_outputs=self.num_classes)
                self.read_out_logits = prediction_fn(self.logits, name='Predictions')
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号