tensorflow 实战Google深度学习框架06_图像识别与卷积神经网络


1. 卷积神经网络常用结构

卷积神经网络

  • 输入层
  • 卷积层:一般来说,通过卷积层处理过的节点矩阵会变得更深
    32x32x3 --> 1x1x10
  • 池化层:池化层神经网络不会改变三维矩阵的深度,但可以缩小矩阵的大小
    28x28x10 --> 14x14x10
  • 全连接层:特征提取完成后,仍需要全连接层来完成分类任务
  • softmax层:通过softmax层,得到当前样例属于不同种类的概率分布情况

1.1 卷积层

1.1.1 过滤器尺寸,步长,输出结果矩阵大小

在这里插入图片描述
在这里插入图片描述
使用全0填充时结果矩阵的长度等于输入层矩阵长度除以长度方向上的步长的向上取整值,宽度为输入层矩阵宽度除以宽度方向上的步长的向上取整值,即:
o u t l e n g t h = ⌈ i n l e n g t h / s t r i d e l e n g t h ⌉ out_{length}=⌈in_{length}/stride_{length}⌉ outlength=inlength/stridelength

o u t w i d t h = ⌈ i n w i d t h / s t r i d e w i d t h ⌉ out_{width}=⌈in_{width}/stride_{width}⌉ outwidth=inwidth/stridewidth

不使用全0填充时结果矩阵的大小为:
o u t l e n g t h = ⌈ ( i n l e n g t h − f i l t e r l e n g t h + 1 ) / s t r i d e l e n g t h ⌉ out_{length}=⌈(in_{length}-filter_{length}+1)/stride_{length}⌉ outlength=(inlengthfilterlength+1)/stridelength

o u t w i d t h = ⌈ ( i n w i d t h − f i l t e r w i d t h + 1 ) / s t r i d e w i d t h ⌉ out_{width}=⌈(in_{width}-filter_{width}+1)/stride_{width}⌉ outwidth=(inwidthfilterwidth+1)/stridewidth

其中,in表示输入,out表示输出,stride表示步长,filter表示过滤器尺寸。

1.1.2 实现一个卷积层前向传播过程

import tensorflow as tf

# 卷积层参数个数只和过滤器尺寸、深度及当前节点深度有关,所以申明的变量是一个四维矩阵
filter_w = tf.get_variable("w", [5, 5, 3, 16], 
                                initializer = tf.truncated_normal_initializer(stddev=0.1))
b = tf.get_variable("b", [16], initializer = tf.constant_initializer(0.1))
conv =tf.nn.conv2d(input, filter_w, strides=[1,1,1,1], padding="SAME")
"""
input 当前层节点矩阵,四维矩阵,第一维对应一个输入batch
filter_w 卷积层权重
strides 不同维度上的步长,第一维和第四维要求为1
padding 填充方法,SAME表示全0填充,VALID表示不添加

"""
bias = tf.nn.bias_add(conv, b) # 给每一个节点加上偏置项
actived_conv = tf.nn.relu(bias)  # relu激活函数曲线性化

1.2 池化层

在这里插入图片描述

1.2.1 最大池化层 平均池化层

# 最大池化层 平均池化层

pool = tf.nn.max_pool(actived_conv, ksize=[1, 3, 3, 1], stides=[1, 2, 2, 1], padding="SAME")
# tf.nn.avg_pool 平均池化层

"""
actived_conv 传入当前层节点矩阵,四维矩阵,第一维对应一个输入batch 
ksize 过滤器尺寸,第一维和第四维要求为1
stides 步长,第一维和第四维要求为1
padding 填充方法,SAME表示全0填充,VALID表示不添加
"""

2. 经典卷积神经网络模型

2.1 tensorflow 实现 LeNet-5 模型

D:\task1\tensorflow_google\chapter06\lenet_5_mnist
lenet_5_01 和 lenet_5_02 都可以运行成功,基本相同

2.1.1 lenet5_mnist_01

# mnist_inference.py
import tensorflow as tf

from tensorflow.examples.tutorials.mnist import input_data
mnist = input_data.read_data_sets("MNIST_data/",one_hot=True)

input_node = mnist.train.images.shape[1] # 784
output_node = mnist.train.labels.shape[1]# 10

image_size = 28
num_channels = 1
num_lables = 10

# 第一层卷积层的尺寸和深度
conv1_deep = 32
conv1_size = 5

# 第二层卷积层的尺寸和深度
conv2_deep = 64
conv2_size = 5

# 全连接层的尺寸和深度
fc_size = 512

def inference(input_tensor, train, regularizer):
    # 定义第一层神经网络的变量和前向传播过程
    # 28*28*1  --》 28*28*32
    with tf.variable_scope("layer1-conv1"):
        conv1_w = tf.get_variable("w", 
                                  [conv1_size, conv1_size, num_channels,conv1_deep],
                                  initializer = tf.truncated_normal_initializer(stddev=0.1))
        
        conv1_b = tf.get_variable("b", [conv1_deep], 
                                  initializer = tf.constant_initializer(0.0))
        
        conv1 =tf.nn.conv2d(input_tensor, conv1_w, strides=[1,1,1,1], padding="SAME")
        relu1 = tf.nn.relu(tf.nn.bias_add(conv1, conv1_b))
       
    # 第二层池化层
    # 28*28*32  --》 14*14*32
    with tf.name_scope("layer2-pool1"):
        pool1 = tf.nn.max_pool(relu1, ksize=[1, 2, 2, 1], strides=[1, 2, 2, 1], padding="SAME")

        
    # 第三层卷积层
    # 14*14*32  --》 14*14*64
    with tf.variable_scope("layer3-conv2"):
        conv2_w = tf.get_variable("w", 
                                  [conv2_size, conv2_size,conv1_deep, conv2_deep],
                                  initializer = tf.truncated_normal_initializer(stddev=0.1))
        
        conv2_b = tf.get_variable("b", [conv2_deep], 
                                  initializer = tf.constant_initializer(0.0))
        
        conv2 =tf.nn.conv2d(pool1, conv2_w, strides=[1,1,1,1], padding="SAME")
        relu2 = tf.nn.relu(tf.nn.bias_add(conv2, conv2_b))
    
    # 第四层池化层
    # 14*14*64  --》 7*7*64
    with tf.name_scope("layer4-pool2"):
        pool2 = tf.nn.max_pool(relu2, ksize=[1, 2, 2, 1], strides=[1, 2, 2, 1], padding="SAME")

        
    # 第四层输出为7*7*64,转化格式为全连接层中的向量,pool_shape[0]为一个batch中数据个数
    pool_shape = pool2.get_shape().as_list()
    nodes = pool_shape[1]*pool_shape[2]*pool_shape[3]
    reshaped = tf.reshape(pool2, [pool_shape[0], nodes])
        
    # 全连接层
    with tf.variable_scope("layer5-fc1"):
        fc1_w = tf.get_variable("w", [nodes, fc_size],
                                  initializer = tf.truncated_normal_initializer(stddev=0.1))
        if regularizer != None:
            tf.add_to_collection("losses", regularizer(fc1_w))
        fc1_b = tf.get_variable("b", [fc_size], initializer = tf.constant_initializer(0.1))
        fc1 = tf.nn.relu(tf.matmul(reshaped, fc1_w) + fc1_b)
        if train: fc1 = tf.nn.dropout(fc1, 0.5)
        
    # 全连接层
    with tf.variable_scope("layer6-fc2"):
        fc2_w = tf.get_variable("w", [fc_size, num_lables],
                                  initializer = tf.truncated_normal_initializer(stddev=0.1))
        if regularizer != None:
            tf.add_to_collection("losses", regularizer(fc2_w))
        fc2_b = tf.get_variable("b", [num_lables], initializer = tf.constant_initializer(0.1))
        logit = tf.matmul(fc1, fc2_w) + fc2_b
        
    return logit
# mnist_train.py
# 设置TensorFlow的日志级别, 消除提示
import os
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'
import numpy as np
import tensorflow as tf
from tensorflow.examples.tutorials.mnist import input_data
import mnist_inference
import matplotlib.pyplot as plt
import matplotlib as mpl
mpl.rcParams['font.sans-serif']=['SimHei']  #指定默认字体 SimHei为黑体
mpl.rcParams['axes.unicode_minus']=False    #用来正常显示负号

batch_size = 100  # 每次batch打包的样本个数
learning_rate_base = 0.01  # 基础学习率 0.8 -> 0.01
learning_rate_decay = 0.99  # 学习率的衰减率
regularization_rate = 0.0001  # 描述模型复杂度的正则化项在损失函数中的系数
training_steps = 6000  # 训练轮数
moving_average_decay = 0.99  # 滑动平均衰减率

model_save_path = "./model/"
model_name = "model.ckpt"


# 训练模型过程
def train(mnist):
    x = tf.placeholder(tf.float32, [batch_size,
                                    mnist_inference.image_size,
                                    mnist_inference.image_size,
                                    mnist_inference.num_channels
                                    ], name="x-input")

    y_ = tf.placeholder(tf.float32,
                        [None, mnist_inference.output_node], name="y-input")

    regularizer = tf.contrib.layers.l2_regularizer(regularization_rate)
    y = mnist_inference.inference(x, train, regularizer)

    # 定义存储训练轮数的变量
    global_step = tf.Variable(0, trainable=False)

    # 初始化滑动平均类
    variable_averages = tf.train.ExponentialMovingAverage(moving_average_decay,
                                                          global_step)
    variable_averages_op = variable_averages.apply(tf.trainable_variables())

    # 在只有一个正确答案的分类中,下面的函数可以加速计算
    cross_entropy = tf.nn.sparse_softmax_cross_entropy_with_logits(
        labels=tf.argmax(y_, 1), logits=y)
    cross_entropy_mean = tf.reduce_mean(cross_entropy)
    loss = cross_entropy_mean + tf.add_n(tf.get_collection("losses"))
    learning_rate = tf.train.exponential_decay(
        learning_rate_base, global_step, mnist.train.num_examples / batch_size,
        learning_rate_decay)

    # 使用衰减学习率。在minimize函数中传入global_step将自动更新global_step参数,
    # 学习率也得到相应更新
    train_step = tf.train.GradientDescentOptimizer(learning_rate).minimize(
        loss, global_step=global_step)
    with tf.control_dependencies([train_step, variable_averages_op]):
        train_op = tf.no_op(name="train")

    saver = tf.train.Saver()
    with tf.Session() as sess:
        tf.global_variables_initializer().run()
        # tf.initialize_all_variables().run()

        step_list = []
        loss_value_list = []
        for i in range(training_steps):
            xs, ys = mnist.train.next_batch(batch_size)
            xs = np.reshape(xs, (batch_size,
                                 mnist_inference.image_size,
                                 mnist_inference.image_size,
                                 mnist_inference.num_channels))
            _, loss_value, step = sess.run([train_op, loss, global_step],
                                           feed_dict={x: xs, y_: ys})
            if (i + 1) % 500 == 0:
                step_list.append(step)
                loss_value_list.append(loss_value)
                saver.save(sess, os.path.join(model_save_path, model_name),
                           global_step=global_step)
                print(step, loss_value)

        print(step_list, loss_value_list)
        plt.scatter(step_list, loss_value_list, c='b',s= 20,linewidths=None,marker='x')
        plt.title('损失函数', fontsize=12)
        plt.show()

def main(argv=None):
    mnist = input_data.read_data_sets("MNIST_data/", one_hot=True)
    train(mnist)


if __name__ == '__main__':
    tf.app.run()

在这里插入图片描述

# mnist_eval.py
import time
import tensorflow as tf
from tensorflow.examples.tutorials.mnist import input_data
import numpy as np
import mnist_inference
import mnist_train
import matplotlib.pyplot as plt
import matplotlib as mpl
mpl.rcParams['font.sans-serif'] = ['SimHei']  # 指定默认字体 SimHei为黑体
mpl.rcParams['axes.unicode_minus'] = False  # 用来正常显示负号

# 每30秒加载一次最新的模型,并在验证数据上计算最新模型的正确率
eval_interval_secs = 20


def evaluate(mnist):
    with tf.Graph().as_default() as g:
        # 定义输入输出的格式
        x = tf.placeholder(tf.float32, [mnist.validation.num_examples,
                                        mnist_inference.image_size,
                                        mnist_inference.image_size,
                                        mnist_inference.num_channels
                                        ], name="x-input")

        y_ = tf.placeholder(tf.float32,
                            [None, mnist_inference.output_node], name="y-input")

        # regularizer = tf.contrib.layers.l2_regularizer(regularization_rate)
        y = mnist_inference.inference(x, False, None)

        # tf.argmax(average_y, 1) 返回行或者列方向上最大值所在的索引
        correct_preds = tf.equal(tf.argmax(y, 1), tf.argmax(y_, 1))  # 返回True or False
        accuracy = tf.reduce_mean(tf.cast(correct_preds, tf.float32))  ##返回 1 or 0

        variable_averages = tf.train.ExponentialMovingAverage(mnist_train.moving_average_decay)
        variables_to_restore = variable_averages.variables_to_restore()
        saver = tf.train.Saver(variables_to_restore)

        #         with tf.Session() as sess:
        #             ckpt = tf.train.get_checkpoint_state(mnist_train.model_save_path)
        #             if ckpt and ckpt.model_checkpoint_path:
        #                 saver.restore(sess, ckpt.model_checkpoint_path)
        #                 global_step = ckpt.model_checkpoint_path.split("/")[-1].split("-")[-1]
        #                 predict_value = sess.run(correct_preds, feed_dict=val_feed_dict)
        #                 accuracy_score = sess.run(accuracy, feed_dict=val_feed_dict)
        #                 print("训练轮数:", global_step, "验证集上准确率:", accuracy_score)

        #                 plt.figure(num=1, figsize=(10, 5),dpi=100, frameon=True)
        #                 plt.scatter(range(len(predict_value)),predict_value, c='b',s= 10,linewidths=10,marker='x')
        #                 plt.show()
        #                 # p1, = plt.scatter(range(len(predict_value)),predict_value, c='b',s= 20,linewidths=None,marker='x')
        #                 # p2, = plt.scatter(range(len(correct_value)),correct_value, c='r',s= 20,linewidths=None,marker='o')
        #                 # p1, = plt.plot(range(len(predict_value)),predict_value,color='blue', linewidth=1, linestyle='-.') # marker="^",markersize=10,
        #                 # p2, = plt.plot(range(len(correct_value)),correct_value,color='red', linewidth=1, linestyle='-.') # marker="*",markersize=10,
        #                 # p1, = plt.plot(range(len(predict_value)),predict_value,"ro",marker="^",markersize=1)
        #                 # p2, = plt.plot(range(len(correct_value)),correct_value,"ro",color='blue',marker="*",markersize=1)
        #                 # plt.legend([p1, p2], ['predict_value', 'predict_value'], fontsize = 'x-large',ncol=3,loc='upper left')

        #             else:
        #                 print("no checkpoint file found")
        #                 return

        # 训练过程中,多次输出结果
        global_step = 0
        global_step_list = []
        accuracy_score_list = []
        while True:
            if global_step != mnist_train.training_steps:
                with tf.Session() as sess:
                    ckpt = tf.train.get_checkpoint_state(mnist_train.model_save_path)
                    if ckpt and ckpt.model_checkpoint_path:
                        xs = mnist.validation.images
                        xs = np.reshape(xs, (mnist.validation.num_examples,
                                             mnist_inference.image_size,
                                             mnist_inference.image_size,
                                             mnist_inference.num_channels))
                        val_feed_dict = {x: xs, y_: mnist.validation.labels}
                        saver.restore(sess, ckpt.model_checkpoint_path)
                        print(ckpt.model_checkpoint_path)
                        global_step = int(ckpt.model_checkpoint_path.split("/")[-1].split("-")[-1])
                        accuracy_score = sess.run(accuracy, feed_dict=val_feed_dict)
                        global_step_list.append(global_step)
                        accuracy_score_list.append(accuracy_score)
                        print("训练轮数:", global_step, "验证集上准确率:", accuracy_score)
                    else:
                        print("no checkpoint file found")
                        return
                time.sleep(eval_interval_secs)
            else:
                break

        plt.figure(num=1, figsize=(10, 5), dpi=100, frameon=True)
        plt.scatter(global_step_list, accuracy_score_list, c='b', s=10, linewidths=10, marker='x')
        plt.title('验证集上准确率')
        plt.show()


def main(argv=None):
    mnist = input_data.read_data_sets("./MNIST_data", one_hot=True)
    evaluate(mnist)


if __name__ == '__main__':
    tf.app.run()

在这里插入图片描述

2.1.2 lenet5_mnist_02

# lenet_inference.py
import tensorflow as tf

# 定义神经网络结构相关的参数
INPUT_NODE = 784
OUTPUT_NODE = 10

IMAGE_SIZE = 28
NUM_CHANNELS = 1
NUM_LABELS = 10
# 第一层卷积层的尺寸和深度
CONV1_DEEP = 32
CONV1_SIZE = 5
# 第二层卷积层的尺寸和深度
CONV2_DEEP = 64
CONV2_SIZE = 5
# 全连接层的节点个数
FC_SIZE = 512

def inference(input_tensor, train, regularizer):
    # 第一层卷积
    with tf.variable_scope('layer1-conv1'):
        conv1_weights = tf.get_variable('weight', [CONV1_SIZE, CONV1_SIZE, NUM_CHANNELS, CONV1_DEEP],
                                        initializer=tf.truncated_normal_initializer(stddev=0.1))
        conv1_biases = tf.get_variable('bias', [CONV1_DEEP],
                                       initializer=tf.constant_initializer(0.0))
        # 使用边长为5,深度为32的过滤器,过滤器移动的步长为1,且使用全0填充
        conv1 = tf.nn.conv2d(input_tensor, conv1_weights, strides=[1, 1, 1, 1], padding='SAME')
        relu1 = tf.nn.relu(tf.nn.bias_add(conv1, conv1_biases))
    # 第二层池化
    with tf.name_scope('layer2-pool1'):
        pool1 = tf.nn.max_pool(relu1, ksize=[1, 2, 2, 1], strides=[1, 2, 2, 1], padding='SAME')
    # 第三层卷积
    with tf.variable_scope('layer3-conv2'):
        conv2_weights = tf.get_variable('weight', [CONV2_SIZE, CONV2_SIZE, CONV1_DEEP, CONV2_DEEP],
                                        initializer=tf.truncated_normal_initializer(stddev=0.1))
        conv2_biases = tf.get_variable('bias', [CONV2_DEEP],
                                       initializer=tf.constant_initializer(0.0))
        # 使用边长为5,深度为64的过滤器,过滤器移动的步长为1,且使用全0填充
        conv2 = tf.nn.conv2d(pool1, conv2_weights, strides=[1, 1, 1, 1], padding='SAME')
        relu2 = tf.nn.relu(tf.nn.bias_add(conv2, conv2_biases))
    # 第四层池化层
    with tf.name_scope('layer4-pool2'):
        pool2 = tf.nn.max_pool(relu2, ksize=[1, 2, 2, 1], strides=[1, 2, 2, 1], padding='SAME')
    # 得到第四层输出矩阵的维度
    pool_shape = pool2.get_shape().as_list()
    # 计算矩阵长宽及深度的乘积
    nodes = pool_shape[1] * pool_shape[2] * pool_shape[3]
    # 通过tf.reshape函数将第四层的输出变成一个batch的向量
    reshaped = tf.reshape(pool2, [pool_shape[0], nodes])
    # 第五层全连接层 加入dropout避免过拟合
    with tf.variable_scope('layer5-fc1'):
        fc1_weights = tf.get_variable('weight', [nodes, FC_SIZE],
                                      initializer=tf.truncated_normal_initializer(stddev=0.1))
        # 只有全连接层的权重需要加入正则化
        if regularizer != None:
            tf.add_to_collection('losses', regularizer(fc1_weights))
        fc1_biases = tf.get_variable('bias', [FC_SIZE], initializer=tf.constant_initializer(0.1))
        fc1 = tf.nn.relu(tf.matmul(reshaped, fc1_weights) + fc1_biases)
        if train: fc1 = tf.nn.dropout(fc1, 0.5)
    # 第六层全连接层
    with tf.variable_scope('layer6-fc2'):
        fc2_weights = tf.get_variable('weight', [FC_SIZE, NUM_LABELS],
                                      initializer=tf.truncated_normal_initializer(stddev=0.1))
        if regularizer != None:
            tf.add_to_collection('losses', regularizer(fc2_weights))
        fc2_biases = tf.get_variable('bias', [NUM_LABELS],
                                     initializer=tf.constant_initializer(0.1))
        logit = tf.matmul(fc1, fc2_weights) + fc2_biases
    # 返回第六层的输出
    return logit
# lenet_train.py
import os
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'
import numpy as np
import tensorflow as tf
from tensorflow.examples.tutorials.mnist import input_data
# 加载lenet_reference.py中定义的常量和前向传播的函数
import lenet_inference
import matplotlib.pyplot as plt
import matplotlib as mpl
mpl.rcParams['font.sans-serif']=['SimHei']  #指定默认字体 SimHei为黑体
mpl.rcParams['axes.unicode_minus']=False    #用来正常显示负号


# 配置神经网络参数
BATCH_SIZE = 100
LEARNING_RATE_BASE = 0.01   # 0.8 -> 0.01
LEARNING_RATE_DECAY = 0.99
REGULARAZTION_RATE = 0.0001
TRAINING_STEPS = 6000
MOVING_AVERAGE_DECAY = 0.99
# 模型保存的路径和文件名
MODEL_SAVE_PATH = './model/' # 当前同级目录下的文件
MODEL_NAME = 'model.ckpt'

def train(mnist):
    # 定义输入输出placeholder
    x = tf.placeholder(tf.float32, [BATCH_SIZE, lenet_inference.IMAGE_SIZE,
                                    lenet_inference.IMAGE_SIZE, lenet_inference.NUM_CHANNELS],
                       name='x-input')
    y_ = tf.placeholder(tf.float32, [None, lenet_inference.OUTPUT_NODE],
                        name='y-input')
    regularizer = tf.contrib.layers.l2_regularizer(REGULARAZTION_RATE)
    # 直接使用mnist_reference.py中定义的前向传播过程
    y = lenet_inference.inference(x, True, regularizer)
    global_step = tf.Variable(0, trainable=False)
    # 定义损失函数、学习率、滑动平均操作以及训练过程
    variable_average = tf.train.ExponentialMovingAverage(
        MOVING_AVERAGE_DECAY, global_step)
    variable_average_op = variable_average.apply(tf.trainable_variables())
    cross_entropy = tf.nn.sparse_softmax_cross_entropy_with_logits(
        logits=y, labels=tf.argmax(y_, 1))
    cross_entropy_mean = tf.reduce_mean(cross_entropy)
    loss = cross_entropy_mean + tf.add_n(tf.get_collection('losses'))
    learning_rate = tf.train.exponential_decay(
        LEARNING_RATE_BASE, global_step,
        mnist.train.num_examples / BATCH_SIZE, LEARNING_RATE_DECAY)
    train_step = tf.train.GradientDescentOptimizer(learning_rate)\
        .minimize(loss, global_step=global_step)
    with tf.control_dependencies([train_step, variable_average_op]):
        train_op = tf.no_op(name='train')
    # 初始化TensorFlow持久化类
    saver = tf.train.Saver()
    with tf.Session() as sess:
        tf.global_variables_initializer().run()
        # 在训练过程中不再测试模型再验证数据上的表现,验证和测试的过程将会有一个独立的程序来完成
        step_list = []
        loss_value_list = []
        for i in range(TRAINING_STEPS):
            xs, ys = mnist.train.next_batch(BATCH_SIZE)
            reshape_xs = np.reshape(xs, (BATCH_SIZE, lenet_inference.IMAGE_SIZE,
                                         lenet_inference.IMAGE_SIZE, lenet_inference.NUM_CHANNELS))
            _, loss_value, step = sess.run([train_op, loss, global_step],
                                           feed_dict={x: reshape_xs, y_: ys})
            # 每1000轮保存一次模型
            if (i+1) % 500 == 0:
                step_list.append(step)
                loss_value_list.append(loss_value)
                print('After %d training step(s), loss on training batch is %g.'
                      % (step, loss_value))
                saver.save(sess, os.path.join(MODEL_SAVE_PATH, MODEL_NAME),
                           global_step=global_step)
        print(step_list, loss_value_list)
        plt.scatter(step_list, loss_value_list, c='b',s= 20,linewidths=None,marker='x')
        plt.title('损失函数', fontsize=12)
        plt.show()

def main(argv=None):
    mnist = input_data.read_data_sets('./MNIST_data', one_hot=True)
    train(mnist)


if __name__ == '__main__':
    tf.app.run()
# lenet_eval.py
import time
import numpy as np
import tensorflow as tf
from tensorflow.examples.tutorials.mnist import input_data

# 加载lenet_inference.py和lenet_train.py中定义的常量和函数
import lenet_inference
import lenet_train

import matplotlib.pyplot as plt
import matplotlib as mpl
mpl.rcParams['font.sans-serif'] = ['SimHei']  # 指定默认字体 SimHei为黑体
mpl.rcParams['axes.unicode_minus'] = False  # 用来正常显示负号

# 每10秒加载一次最新的模型,并在测试数据上测试最新模型的正确率
EVAL_INTERVAL_SECS = 10

def evaluate(mnist):
    with tf.Graph().as_default() as g:
        x = tf.placeholder(tf.float32, [mnist.validation.num_examples, lenet_inference.IMAGE_SIZE,
                                        lenet_inference.IMAGE_SIZE, lenet_inference.NUM_CHANNELS],
                           name='x-input')
        y_ = tf.placeholder(tf.float32, [None, lenet_inference.OUTPUT_NODE],
                            name='y-input')


        y = lenet_inference.inference(x, False, None)
        correct_prediction = tf.equal(tf.argmax(y, 1), tf.arg_max(y_, 1))
        accuracy = tf.reduce_mean(tf.cast(correct_prediction, tf.float32))

        variable_averages = tf.train.ExponentialMovingAverage(lenet_train.MOVING_AVERAGE_DECAY)
        variables_to_restore = variable_averages.variables_to_restore()
        saver = tf.train.Saver(variables_to_restore)

        global_step = 0
        global_step_list = []
        accuracy_score_list = []
        while True:
            if global_step != lenet_train.TRAINING_STEPS:
                with tf.Session() as sess:
                    # tf.train.get_checkpoint_state函数会通过checkpoint文件自动找到目录中最新模型的文件名
                    ckpt = tf.train.get_checkpoint_state(lenet_train.MODEL_SAVE_PATH)
                    if ckpt and ckpt.model_checkpoint_path:
                        vx = np.reshape(mnist.validation.images, (mnist.validation.num_examples, lenet_inference.IMAGE_SIZE,
                                                                  lenet_inference.IMAGE_SIZE, lenet_inference.NUM_CHANNELS))
                        vy = mnist.validation.labels
                        validate_feed = {x: vx, y_: vy}
                        # 加载模型
                        saver.restore(sess, ckpt.model_checkpoint_path)
                        # 通过文件名得到模型保存时保存时迭代的轮数
                        print(ckpt.model_checkpoint_path)
                        global_step = int(ckpt.model_checkpoint_path.split('/')[-1].split('-')[-1])
                        accuracy_score = sess.run(accuracy, feed_dict=validate_feed)
                        global_step_list.append(global_step)
                        accuracy_score_list.append(accuracy_score)

                        print('After %g training step(s), validation accuracy = %g'
                              % (global_step, accuracy_score))
                    else:
                        print('No checkpoint file found')
                        return
                time.sleep(EVAL_INTERVAL_SECS)
            else:
                break
        plt.figure(num=1, figsize=(10, 5), dpi=100, frameon=True)
        plt.scatter(global_step_list, accuracy_score_list, c='b', s=10, linewidths=10, marker='x')
        plt.title("验证集上准确率")
        plt.show()


def main(argv=None):
    mnist = input_data.read_data_sets('./MNIST_data', one_hot=True)
    evaluate(mnist)


if __name__ == '__main__':
    tf.app.run()

在这里插入图片描述

2.2 tensorflow 实现 Inception-v3 模型

2.2.1 Inception-v3 模型介绍

lenet-5模型中,不同卷积层通过串联的方式连接在一起,而inception-v3模型中的inception结构是将不同的卷积层通过并联的方式连接在一起,同时使用多个不同尺寸的过滤器,将得到的矩阵拼接起来,将它们在深度这个维度上组合起来

with tf.variable_scope("layer3-conv2"):
    conv2_w = tf.get_variable("w", [conv2_size, conv2_size,conv1_deep, conv2_deep],
                              initializer = tf.truncated_normal_initializer(stddev=0.1))

    conv2_b = tf.get_variable("b", [conv2_deep], 
                              initializer = tf.constant_initializer(0.0))

    conv2 =tf.nn.conv2d(pool1, conv2_w, strides=[1,1,1,1], padding="SAME")
    relu2 = tf.nn.relu(tf.nn.bias_add(conv2, conv2_b))
    
    
net = slim.conv2d(input, 32, [3,3])
"""
第一个参数 输入节点矩阵
第二个参数 当前卷积层过滤器的深度
第三个参数 过滤器尺寸
可选参数还有 过滤器移动的步长,是否全0填充,激活函数选择,变量命名空间等
"""

2.2.2 Inception 模块的代码实现

"""
slim.arg_scopeZ设置默认参数取值。第一个参数是一个函数列表,这个列表中的函数将使用
默认参数取值

"""

with slim.arg_scope([slim.conv2d, slim.max_pool2d, slim.avg_pool2d], 
                    stride=1, padding='SAME'):
    ...# 省略inception-v3模型中其他网络结构
    net = ...# 上一层输出节点矩阵
    # 为一个inception模块申明一个统一的变量命名空间
    with tf.variable_scope('Mixed_7c'):
        
        # 给inception模块中每一条路径申明一个命名空间
        with tf.variable_scope('Branch_0'):
            # 实现一个过滤器边长为1,深度为320的卷积层
            branch_0 = slim.conv2d(net, 320, [1,1], scope='Conv2d_0a_1x1')
        
        # inception模块中第二条路径,这条计算路径上的结构本身也是一个inception结构
        with tf.variable_scope('Branch_1'):
            branch_1 = slim.conv2d(net, 384, [1,1], scope='Conv2d_0a_1x1')
            
            # tf.concat哈数可以将多个矩阵拼接起来。
            '''
            第一个参数指定拼接维度,‘3’表示在深度这个维度上进行拼接
            两层卷积层的输入都是branch_1,而不是net
            '''
            branch_1 = tf.concat(3,[
                slim.conv2d(branch_1, 384, [1,3], scope='Conv2d_0b_1x3'),
                slim.conv2d(branch_1, 384, [3,1], scope='Conv2d_0c_3x1')])
            
        # inception模块中第三条路径,这条计算路径上的结构本身也是一个inception结构
        with tf.variable_scope('Branch_2'):
            branch_2 = slim.conv2d(net, 448, [1,1], scope='Conv2d_0a_1x1')
            branch_2 = slim.conv2d(branch_2, 384, [3,3], scope='Conv2d_0b_3x3')
            branch_2 = tf.concat(3,[
                slim.conv2d(branch_2, 384, [1,3], scope='Conv2d_0c_1x3'),
                slim.conv2d(branch_2, 384, [3,1], scope='Conv2d_0d_3x1')])
            
        # inception模块中第四条路径
        with tf.variable_scope('Branch_3'):
            branch_3 = slim.avg_pool2d(net, [3,3], scope='AvgPool_0a_3x3')
            branch_3 = slim.conv2d(branch_3, 192, [1,1], scope='Conv2d_0b_1x1')
            
        # 当前inception模块的最后输出是上面四个计算结果拼接得到的
        net = tf.concat(3, [Branch_0, Branch_1, Branch_2, Branch_3])
        

3. 卷积神经网络迁移学习

3.1 tensorflow 实现迁移学习

D:\task1\tensorflow_google\chapter06_lenet5_inceptionv3_migrationlearning\migration_learning_flower
代码 http://www.cnblogs.com/Cucucudeblog/p/10159025.html
代码 https://blog.csdn.net/longji/article/details/69948905
数据集,代码 https://blog.csdn.net/nnnnnnnnnnnny/article/details/70244232

利用ImageNet数据集上训练好的inception-v3模型解决一个新的图像分类问题。可以保留训练好的
inception-v3模型中所有卷积层的参数,只是替换最后一层全连接层

3.1.1 cmd命令 数据集的下载

#利用curl下载数据集
curl -o flower_photos.tgz http://download.tensorflow.org/example_images/flower_photos.tgz
#在当前路径下对下载的数据集进行解压
tar xzf flower_photos.tgz

3.1.2 下载谷歌提供的训练好的Inception-v3模型

参考 https://blog.csdn.net/nnnnnnnnnnnny/article/details/70244232

#Linux、Unix下使用,window下需要下载文件
wget -P /Volumes/Cu/QianXi_Learning --no-check-certificate https://storage.googleapis.com/download.tensorflow.org/models/inception_dec_2015.zip
#解压所训练好的模型
unzip /Volumes/Cu/QianXi_Learning/inception_dec_2015.zip

3.1.3 transfer_flower.py

“D:\task1\tensorflow_google\chapter06_lenet5_inceptionv3_migrationlearning\migration_learning_flower\transfer_flower.py”

#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import glob
import os.path
import random
import numpy as np
import tensorflow as tf
from tensorflow.python.platform import gfile

# Inception-v3模型瓶颈层的节点个数
BOTTLENECK_TENSOR_SIZE = 2048

# Inception-v3模型中代表瓶颈层结果的张量名称。
# 在谷歌提出的Inception-v3模型中,这个张量名称就是'pool_3/_reshape:0'。
# 在训练模型时,可以通过tensor.name来获取张量的名称。
BOTTLENECK_TENSOR_NAME = 'pool_3/_reshape:0'

# 图像输入张量所对应的名称。
JPEG_DATA_TENSOR_NAME = 'DecodeJpeg/contents:0'

# 下载的谷歌训练好的Inception-v3模型文件目录
MODEL_DIR = 'model/'

# 下载的谷歌训练好的Inception-v3模型文件名
MODEL_FILE = 'tensorflow_inception_graph.pb'

# 因为一个训练数据会被使用多次,所以可以将原始图像通过Inception-v3模型计算得到的特征向量保存在文件中,免去重复的计算。
# 下面的变量定义了这些文件的存放地址。
CACHE_DIR = 'tmp/bottleneck/'

# 图片数据文件夹。
# 在这个文件夹中每一个子文件夹代表一个需要区分的类别,每个子文件夹中存放了对应类别的图片。
INPUT_DATA = 'flower_photos/'

# 验证的数据百分比
VALIDATION_PERCENTAGE = 10
# 测试的数据百分比
TEST_PERCENTAGE = 10

# 定义神经网络的设置
LEARNING_RATE = 0.01
STEPS = 4000
BATCH = 100

# 这个函数从数据文件夹中读取所有的图片列表并按训练、验证、测试数据分开。
# testing_percentage和validation_percentage参数指定了测试数据集和验证数据集的大小。
def create_image_lists(testing_percentage, validation_percentage):
    # 得到的所有图片都存在result这个字典(dictionary)里。
    # 这个字典的key为类别的名称,value也是一个字典,字典里存储了所有的图片名称。
    result = {}
    # 获取当前目录下所有的子目录
    sub_dirs = [x[0] for x in os.walk(INPUT_DATA)]
    # 得到的第一个目录是当前目录,不需要考虑
    is_root_dir = True
    for sub_dir in sub_dirs:
        if is_root_dir:
            is_root_dir = False
            continue

        # 获取当前目录下所有的有效图片文件。
        # extensions = ['jpg', 'jpeg', 'JPG', 'JPEG']
        extensions = ['jpg', 'jpeg']
        file_list = []
        dir_name = os.path.basename(sub_dir)
        for extension in extensions:
            file_glob = os.path.join(INPUT_DATA, dir_name, '*.'+extension)
            file_list.extend(glob.glob(file_glob))
        if not file_list:
            continue

        # 通过目录名获取类别的名称。
        label_name = dir_name.lower()
        # 初始化当前类别的训练数据集、测试数据集和验证数据集
        training_images = []
        testing_images = []
        validation_images = []
        for file_name in file_list:
            base_name = os.path.basename(file_name)
            # 随机将数据分到训练数据集、测试数据集和验证数据集。
            chance = np.random.randint(100)
            if chance < validation_percentage:
                validation_images.append(base_name)
            elif chance < (testing_percentage + validation_percentage):
                testing_images.append(base_name)
            else:
                training_images.append(base_name)

        # 将当前类别的数据放入结果字典。
        result[label_name] = {
            'dir': dir_name,
            'training': training_images,
            'testing': testing_images,
            'validation': validation_images
            }
    # 返回整理好的所有数据
    return result


# 这个函数通过类别名称、所属数据集和图片编号获取一张图片的地址。
# image_lists参数给出了所有图片信息。
# image_dir参数给出了根目录。存放图片数据的根目录和存放图片特征向量的根目录地址不同。
# label_name参数给定了类别的名称。
# index参数给定了需要获取的图片的编号。
# category参数指定了需要获取的图片是在训练数据集、测试数据集还是验证数据集。
def get_image_path(image_lists, image_dir, label_name, index, category):
    # 获取给定类别中所有图片的信息。
    label_lists = image_lists[label_name]
    # 根据所属数据集的名称获取集合中的全部图片信息。
    category_list = label_lists[category]
    mod_index = index % len(category_list)
    # 获取图片的文件名。
    base_name = category_list[mod_index]
    sub_dir = label_lists['dir']
    # 最终的地址为数据根目录的地址 + 类别的文件夹 + 图片的名称
    full_path = os.path.join(image_dir, sub_dir, base_name)
    return full_path


# 这个函数通过类别名称、所属数据集和图片编号获取经过Inception-v3模型处理之后的特征向量文件地址。
def get_bottlenect_path(image_lists, label_name, index, category):
    return get_image_path(image_lists, CACHE_DIR, label_name, index, category) + '.txt';


# 这个函数使用加载的训练好的Inception-v3模型处理一张图片,得到这个图片的特征向量。
def run_bottleneck_on_image(sess, image_data, image_data_tensor, bottleneck_tensor):
    # 这个过程实际上就是将当前图片作为输入计算瓶颈张量的值。这个瓶颈张量的值就是这张图片的新的特征向量。
    bottleneck_values = sess.run(bottleneck_tensor, {image_data_tensor: image_data})
    # 经过卷积神经网络处理的结果是一个四维数组,需要将这个结果压缩成一个特征向量(一维数组)
    bottleneck_values = np.squeeze(bottleneck_values)
    return bottleneck_values


# 这个函数获取一张图片经过Inception-v3模型处理之后的特征向量。
# 这个函数会先试图寻找已经计算且保存下来的特征向量,如果找不到则先计算这个特征向量,然后保存到文件。
def get_or_create_bottleneck(sess, image_lists, label_name, index, category, jpeg_data_tensor, bottleneck_tensor):
    # 获取一张图片对应的特征向量文件的路径。
    label_lists = image_lists[label_name]
    sub_dir = label_lists['dir']
    sub_dir_path = os.path.join(CACHE_DIR, sub_dir)
    if not os.path.exists(sub_dir_path):
        os.makedirs(sub_dir_path)
    bottleneck_path = get_bottlenect_path(image_lists, label_name, index, category)
    # 如果这个特征向量文件不存在,则通过Inception-v3模型来计算特征向量,并将计算的结果存入文件。
    if not os.path.exists(bottleneck_path):
        # 获取原始的图片路径
        image_path = get_image_path(image_lists, INPUT_DATA, label_name, index, category)
        # 获取图片内容。
        image_data = gfile.FastGFile(image_path, 'rb').read()
        # print(len(image_data))
        # 由于输入的图片大小不一致,此处得到的image_data大小也不一致(已验证),但却都能通过加载的inception-v3模型生成一个2048的特征向量。具体原理不详。
        # 通过Inception-v3模型计算特征向量
        bottleneck_values = run_bottleneck_on_image(sess, image_data, jpeg_data_tensor, bottleneck_tensor)
        # 将计算得到的特征向量存入文件
        bottleneck_string = ','.join(str(x) for x in bottleneck_values)
        with open(bottleneck_path, 'w') as bottleneck_file:
            bottleneck_file.write(bottleneck_string)
    else:
        # 直接从文件中获取图片相应的特征向量。
        with open(bottleneck_path, 'r') as bottleneck_file:
            bottleneck_string = bottleneck_file.read()
        bottleneck_values = [float(x) for x in bottleneck_string.split(',')]
    # 返回得到的特征向量
    return bottleneck_values


# 这个函数随机获取一个batch的图片作为训练数据。
def get_random_cached_bottlenecks(sess, n_classes, image_lists, how_many, category,
                                  jpeg_data_tensor, bottleneck_tensor):
    bottlenecks = []
    ground_truths = []
    for _ in range(how_many):
        # 随机一个类别和图片的编号加入当前的训练数据。
        label_index = random.randrange(n_classes)
        label_name = list(image_lists.keys())[label_index]
        image_index = random.randrange(65536)
        bottleneck = get_or_create_bottleneck(sess, image_lists, label_name, image_index, category,
                                              jpeg_data_tensor, bottleneck_tensor)
        ground_truth = np.zeros(n_classes, dtype=np.float32)
        ground_truth[label_index] = 1.0
        bottlenecks.append(bottleneck)
        ground_truths.append(ground_truth)
    return bottlenecks, ground_truths


# 这个函数获取全部的测试数据。在最终测试的时候需要在所有的测试数据上计算正确率。
def get_test_bottlenecks(sess, image_lists, n_classes, jpeg_data_tensor, bottleneck_tensor):
    bottlenecks = []
    ground_truths = []
    label_name_list = list(image_lists.keys())
    # 枚举所有的类别和每个类别中的测试图片。
    for label_index, label_name in enumerate(label_name_list):
        category = 'testing'
        for index, unused_base_name in enumerate(image_lists[label_name][category]):
            # 通过Inception-v3模型计算图片对应的特征向量,并将其加入最终数据的列表。
            bottleneck = get_or_create_bottleneck(sess, image_lists, label_name, index, category,
                                                  jpeg_data_tensor, bottleneck_tensor)
            ground_truth = np.zeros(n_classes, dtype = np.float32)
            ground_truth[label_index] = 1.0
            bottlenecks.append(bottleneck)
            ground_truths.append(ground_truth)
    return bottlenecks, ground_truths


def main(_):
    # 读取所有图片。
    image_lists = create_image_lists(TEST_PERCENTAGE, VALIDATION_PERCENTAGE)
    n_classes = len(image_lists.keys())
    # 读取已经训练好的Inception-v3模型。
    # 谷歌训练好的模型保存在了GraphDef Protocol Buffer中,里面保存了每一个节点取值的计算方法以及变量的取值。
    # TensorFlow模型持久化的问题在第5章中有详细的介绍。
    with tf.gfile.GFile(os.path.join(MODEL_DIR, MODEL_FILE), 'rb') as f:
        graph_def = tf.GraphDef()
        graph_def.ParseFromString(f.read())
    # 加载读取的Inception-v3模型,并返回数据输入所对应的张量以及计算瓶颈层结果所对应的张量。
    bottleneck_tensor, jpeg_data_tensor = tf.import_graph_def(graph_def, return_elements=[BOTTLENECK_TENSOR_NAME, JPEG_DATA_TENSOR_NAME])
    # bottleneck_values = sess.run(bottleneck_tensor, {image_data_tensor: image_data})


    # 定义新的神经网络输入,这个输入就是新的图片经过Inception-v3模型前向传播到达瓶颈层时的结点取值。
    # 可以将这个过程类似的理解为一种特征提取。
    bottleneck_input = tf.placeholder(tf.float32, [None, BOTTLENECK_TENSOR_SIZE], name='BottleneckInputPlaceholder')
    # 定义新的标准答案输入
    ground_truth_input = tf.placeholder(tf.float32, [None, n_classes], name='GroundTruthInput')
    # 定义一层全连接层来解决新的图片分类问题。
    # 因为训练好的Inception-v3模型已经将原始的图片抽象为了更加容易分类的特征向量了,所以不需要再训练那么复杂的神经网络来完成这个新的分类任务。
    with tf.name_scope('final_training_ops'):
        weights = tf.Variable(tf.truncated_normal([BOTTLENECK_TENSOR_SIZE, n_classes], stddev=0.001))
        biases = tf.Variable(tf.zeros([n_classes]))
        logits = tf.matmul(bottleneck_input, weights) + biases
        final_tensor = tf.nn.softmax(logits)
    # 定义交叉熵损失函数
    cross_entropy = tf.nn.softmax_cross_entropy_with_logits(logits=logits, labels=ground_truth_input)
    cross_entropy_mean = tf.reduce_mean(cross_entropy)
    train_step = tf.train.GradientDescentOptimizer(LEARNING_RATE).minimize(cross_entropy_mean)
    # 计算正确率
    with tf.name_scope('evaluation'):
        correct_prediction = tf.equal(tf.argmax(final_tensor, 1), tf.argmax(ground_truth_input, 1))
        evaluation_step = tf.reduce_mean(tf.cast(correct_prediction, tf.float32))

    with tf.Session() as sess:
        tf.global_variables_initializer().run()
        # 训练过程
        for i in range(STEPS):
            # 每次获取一个batch的训练数据
            train_bottlenecks, train_ground_truth = get_random_cached_bottlenecks(
                sess, n_classes, image_lists, BATCH, 'training', jpeg_data_tensor, bottleneck_tensor)
            sess.run(train_step, feed_dict={bottleneck_input: train_bottlenecks, ground_truth_input: train_ground_truth})
            # 在验证集上测试正确率。
            if i%100 == 0 or i+1 == STEPS:
                validation_bottlenecks, validation_ground_truth = get_random_cached_bottlenecks(
                    sess, n_classes, image_lists, BATCH, 'validation', jpeg_data_tensor, bottleneck_tensor)
                validation_accuracy = sess.run(evaluation_step, feed_dict={
                    bottleneck_input:validation_bottlenecks, ground_truth_input: validation_ground_truth})
                print('Step %d: Validation accuracy on random sampled %d examples = %.1f%%'
                      % (i, BATCH, validation_accuracy*100))
        # 在最后的测试数据上测试正确率
        test_bottlenecks, test_ground_truth = get_test_bottlenecks(sess, image_lists, n_classes,
                                                                       jpeg_data_tensor, bottleneck_tensor)
        test_accuracy = sess.run(evaluation_step, feed_dict={bottleneck_input: test_bottlenecks,
                                                                 ground_truth_input: test_ground_truth})
        print('Final test accuracy = %.1f%%' % (test_accuracy * 100))


if __name__ == '__main__':
    tf.app.run()

8 484 76 73
8 705 85 108
8 505 63 73
8 561 74 64
8 609 90 100

Step 3000: Validation accuracy on random sampled 100 examples = 97.0%
Step 3100: Validation accuracy on random sampled 100 examples = 85.0%
Step 3200: Validation accuracy on random sampled 100 examples = 92.0%
Step 3300: Validation accuracy on random sampled 100 examples = 89.0%
Step 3400: Validation accuracy on random sampled 100 examples = 88.0%
Step 3500: Validation accuracy on random sampled 100 examples = 86.0%
Step 3600: Validation accuracy on random sampled 100 examples = 88.0%
Step 3700: Validation accuracy on random sampled 100 examples = 89.0%
Step 3800: Validation accuracy on random sampled 100 examples = 91.0%
Step 3900: Validation accuracy on random sampled 100 examples = 87.0%
Step 3999: Validation accuracy on random sampled 100 examples = 92.0%
Final test accuracy = 87.4%
An exception has occurred, use %tb to see the full traceback.

3.2 查看图片信息

import matplotlib.pyplot as plt 
import tensorflow as tf 
 
#tf.gfileGFile()函数:读取图像 
image_path = r"D:\task1\tensorflow_google\flower\flower_photos\daisy\5547758_eea9edfd54_n.jpg"
image_jpg = tf.gfile.GFile(image_path,'rb').read()  
# image_png = tf.gfile.FastGFile('lizard.png','rb').read()  
 
with tf.Session() as sess:  
 
    image_jpg = tf.image.decode_jpeg(image_jpg) #图像解码
    image_jpg=sess.run(image_jpg) #解码后的图像(即为一个三维矩阵[w,h,3])
    print(image_jpg.shape, image_jpg)
    
    image_jpg = tf.image.convert_image_dtype(image_jpg,dtype=tf.uint8) #改变图像数据类型  
    print(image_jpg.shape, image_jpg, type(image_jpg))
    plt.figure(1) #图像显示  
    plt.imshow(image_jpg.eval())
    
#     image_png = tf.image.decode_png(image_png) 
#     print(sess.run(image_jpg))
#     image_png = tf.image.convert_image_dtype(image_png,dtype=tf.uint8)    
#     plt.figure(2)  
#     plt.imshow(image_png.eval())  
from PIL import Image
import numpy as np
import matplotlib.pyplot as plt

image_path = r"D:\task1\tensorflow_google\flower\flower_photos\daisy\5547758_eea9edfd54_n.jpg"
img=np.array(Image.open(image_path)) #打开图像并转化为数字矩阵
plt.figure("dog")
plt.imshow(img)
plt.axis('off')
plt.show()

print(img.shape)
print(img.dtype) 
print(img.size)
print(type(img))
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值