对论文 Deep Learning with Limited Numerical Precision 的理解与结论的验证

文章思想:在深度学习中使用定点数来代替浮点数。传统的定点数取舍是最近邻取舍,本文引出了一种新的取舍方式:随机取舍 。即在产生下溢的时候是随机舍入到跟它最接近的两个数之一,其概率与他们之间的距离成反比。如 x=1.735 要保留一位小数,那么距离它最近的两个数分别是 1.7和1.8 。因为 |x-1.7|=0.35,|x-1.8|=0.65 所以x舍为1.7的概率是65%,入为1.8的概率是35%
论文中说这样的可以使得期望误差达到0。比最近邻舍入效果好一些。
浮点数量化为定点数的好处在于:
1.浮点数运算慢,每次运算要对阶之类的操作
2.定点数可以用一半的bit位达到浮点数的效果,可以节省空间

以下是论文中给出的这两种取舍方法的定义:

在这里插入图片描述符号意义:
IL:定点数的整数位数
FL:定点数的小数部分
<IL,FL>:表示一个定点数
WL:表示定点数的位数 ,即WL=IL+FL
x:表示原数字
e:表示最小的单位 e=2^(-FL)
Round-to-nearest:表示最近邻取舍
Stochastic:随机取舍
w.p:以概率为…

.
.
.
.
如果上溢了,则用最大或者最小的来代替它
在这里插入图片描述
.
.
.
.
论文接着设计实验来比对了该结论:
.

(一)使用mnist数据集在DNN上的效果如下:
在这里插入图片描述
上面两幅图是采用16位的定点数,在最近邻舍入的情况下和32bit浮点数之间的比对,左边是训练集的误差(注意:训练集没有百分号),右边是测试集的误差。当然他们都没有浮点数好,但是随机舍入更加接近浮点数效果。
下面两幅图是采用16位定点数,在随机舍入的情况下和浮点数的比对,同样左边训练数据集,右边测试数据集。可以发现表现上跟浮点数相当了
.
.

(二)使用mnist数据集在CNN上的效果如下:
在这里插入图片描述(三)实验设计部分:

使用浮点数DNN全连接网络在mnist上的效果:
DNN网络结构如下:
两个隐层都是1000个结点
初始化连接权:均值为0,方差为0.01的正太分布,即N(0,0.01)
初始化偏置:全0
采用随机梯度下降,每次batch=100

结果:在测试数据集上的误差为1.4%
在这里插入图片描述对此我用tensorflow来验证了一下:
同时使用了l2正则化和学习效率逐步递减的小操作。看论文中是训练了30轮。因为mnist数据集训练集有55000个,一个batch是100,所以应该迭代 30*55000/100=16500次,每55000/100=550次输出一次结果。实验结果与论文中基本一致
调试了好久,正则化参数最终设置为0.005

import tensorflow as tf
from tensorflow.examples.tutorials.mnist import input_data
batch=100
input_node = 28*28
output_node = 10
fc_node1 = 1000
fc_node2=1000
regularization_rate=0.0005
epoch=40000
def trains(mnist):
    init = tf.truncated_normal_initializer(stddev=0.01)
    initb = tf.constant_initializer(0.0)
    x=tf.compat.v1.placeholder(dtype=tf.float32,shape=[None,input_node],name='x-input')
    y_=tf.compat.v1.placeholder(dtype=tf.float32,shape=[None,output_node],name='y-input')

    weight1=tf.get_variable("weight1",[input_node,fc_node1],initializer=init)
    bias1=tf.get_variable('bais1',[fc_node1],initializer=initb)
    weight2=tf.get_variable('weight2',[fc_node1,fc_node2],initializer=init)
    bias2=tf.get_variable('bias2',[fc_node2],initializer=initb)
    weight3 = tf.get_variable('weight3', [fc_node2, output_node], initializer=init)
    bias3=tf.get_variable('bias3',[output_node],initializer=initb)

    hidden1 = tf.nn.relu(tf.matmul(x, weight1) + bias1)
    hidden2=tf.nn.relu(tf.matmul(hidden1,weight2)+bias2)
    y=tf.matmul(hidden2,weight3)+bias3
    regularizer = tf.contrib.layers.l2_regularizer(regularization_rate)
    loss=regularizer(weight1)+regularizer(weight2)
    global_step = tf.Variable(0, trainable=False)
    losses=loss+tf.reduce_mean(tf.nn.sparse_softmax_cross_entropy_with_logits(logits=y, labels=tf.argmax(y_, 1)))

    learning_rate = tf.compat.v1.train.exponential_decay(0.8, global_step, mnist.train.num_examples / batch, 0.95)

    train_step = tf.compat.v1.train.GradientDescentOptimizer(learning_rate).minimize(losses, global_step=global_step)
    correct_prediction = tf.equal(tf.argmax(y, 1), tf.argmax(y_, 1))
    accuracy = tf.reduce_mean(tf.cast(correct_prediction, tf.float32))
    with tf.compat.v1.Session() as sess:
        tf.global_variables_initializer().run()
        validata_feed = {x: mnist.validation.images, y_: mnist.validation.labels}
        test_feed = {x: mnist.test.images, y_: mnist.test.labels}
        for i in range(epoch):
            if i % 1000 == 0:
                validata_acc = sess.run(accuracy, feed_dict=validata_feed)
                print("训练 %d 轮后,训练数据集的精度为: %g%%" % (i, validata_acc*100))
                print("当前学习效率为:%g"%(sess.run(learning_rate)))
            if i%5000==0:
                test_acc = sess.run(accuracy, feed_dict=test_feed)
                print("训练 %d 轮后,测试数据集的精度为: %g%%" % ( i, test_acc*100,))
            xs, ys = mnist.train.next_batch(batch)
            sess.run(train_step, feed_dict={x: xs, y_: ys})

        test_acc = sess.run(accuracy, feed_dict=test_feed)
        print("训练 %d 轮后,测试数据集的精度为: %g%%" % (epoch, test_acc * 100,))


def main(argv=None):
    mnist = input_data.read_data_sets("C:/Users/tang/Desktop/deeplearning/mnist数据集", one_hot=True)
    trains(mnist)
    
if __name__ == '__main__':
    tf.app.run()


运行结果如下:

训练 0 轮后,验证数据集的精度为: 11.63%
训练 0 轮后,训练数据集的精度为: 11.4927%
训练 1 轮后,验证数据集的精度为: 96.34%
训练 1 轮后,训练数据集的精度为: 96.6564%
训练 2 轮后,验证数据集的精度为: 96.94%
训练 2 轮后,训练数据集的精度为: 97.6182%
......
训练 28 轮后,验证数据集的精度为: 98.53%
训练 28 轮后,训练数据集的精度为: 99.9927%
训练 29 轮后,验证数据集的精度为: 98.54%
训练 29 轮后,训练数据集的精度为: 99.9891%
训练 30 轮后,测试数据集的精度为: 98.62%

最终结果测试数据集精度为98.62%,误差是1.38%
.
图像大概这样:
在这里插入图片描述
.
.
下面把浮点数改为定点数,折腾了两天后才把程序写完。

tensorflow是个静态的框架,当模型搭建好后就不能动态的改变了,并且框架里并没有定点数这个数据类型。后来想到了一个办法,每训练一次,把网络里的权值读取出来,进行量化后再存进去。这样可以间接的使用定点数,这种方法在计算中还是使用的浮点数,这是框架本身不能避免的。如果想自己构建这个网络太耗时了,而且效率远不如框架。所以只能间接使用这个验证方法。

以下是量化程序:

FL = 8  # 小数部分位数
IL = 16-FL  # 整数部分位数
round = False  # False 是最近邻取舍,True 是随机取舍
MIN = -(1 << (IL - 1))
MAX = -MIN - 2 ** (-FL)
# 量化范围是[  -2^(IL-1)~2^(IL-1)-2^(-IF)  ]
def float_to_fixed(x):

    global MIN, MAX, FL
    #print(FL)
    if x <= MIN: return MIN
    if x >= MAX: return MAX
    sig = 1
    if x < 0:
        sig = -1
        x = -x
    q = int(x)
    x -= q
    e = 1
    for i in range(FL):
        x *= 2
        e /= 2
        if x >= 1:
            x -= 1
            q += e

    if round:  # 随机舍入
        r = random()  # 产生0-1的随机数
        if r < x:
            q += e
    else:  # 邻近舍入
        if x >= 0.5:
            q += e
    q *= sig
    if q <= MIN: return MIN
    if q >= MAX: return MAX
    return q

捣鼓了一天把它和tensorflow对接上了,可是运行效率太低了。后来查了下原因,是因为python语言本身就慢,用python写的量化程序运算效率远远低于tensorflow的效率,估计相差50倍左右。于是晚上逛知乎发现了一个宝贝—— numba ,用用numba 的jit 可以把python中的高密度计算和循环加速几十倍,它是通过预编译把python代码处理成本地的汇编语言,从而达到和c语言一样的速度,而且代码写得越像c++,加速越明显。第二天赶紧加上这个神奇的操作后,终于能跑起来了。看cup的占用率应该基本能匹配上tensorflow的速度了。

以下是完整代码

import tensorflow as tf
from random import random
from tensorflow.examples.tutorials.mnist import input_data
import os
from numba import jit, int32, float32, boolean, cuda
from matplotlib import pyplot as plt

os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'
batch = 100
input_node = 28 * 28
output_node = 10
fc_node1 = 1000
fc_node2 = 1000
regularization_rate = 0.0001
epoch = 16500


FL = 8  # 小数部分位数
IL = 16-FL  # 整数部分位数
round = False  # False 是最近邻取舍,True 是随机取舍
# 论文要验证 FL=8,10,14 round=False 和 FL=8,10,14 round=True 这六种情况
# 量化范围是[  -2^(IL-1)~2^(IL-1)-2^(-IF)  ]
MIN = -(1 << (IL - 1))
MAX = -MIN - 2 ** (-FL)

@jit(float32(float32), nopython=True)
def float_to_fixed(x):

    global MIN, MAX, FL
    #print(FL)
    if x <= MIN: return MIN
    if x >= MAX: return MAX
    sig = 1
    if x < 0:
        sig = -1
        x = -x
    q = int(x)
    x -= q
    e = 1
    for i in range(FL):
        x *= 2
        e /= 2
        if x >= 1:
            x -= 1
            q += e

    if round:  # 随机舍入
        r = random()  # 产生0-1的随机数
        if r < x:
            q += e
    else:  # 邻近舍入
        if x >= 0.5:
            q += e

    q *= sig
    if q <= MIN: return MIN
    if q >= MAX: return MAX
    return q


@jit(nopython=True)
def exchange2(arr):
    for i in range(arr.shape[0]):
        for j in range(arr.shape[1]):
            arr[i, j] = float32(arr[i, j])
            arr[i, j] = float_to_fixed(arr[i, j])
    return None


@jit(nopython=True)
def exchange1(arr):
    for i in range(arr.shape[0]):
        arr[i] = float_to_fixed(arr[i])

    return None


train_error = []
test_error = []


def trains(mnist):
    init = tf.truncated_normal_initializer(stddev=0.01)
    initb = tf.constant_initializer(0.0)
    x = tf.compat.v1.placeholder(dtype=tf.float32, shape=[None, input_node], name='x-input')
    y_ = tf.compat.v1.placeholder(dtype=tf.float32, shape=[None, output_node], name='y-input')

    Swap_weight1 = tf.compat.v1.placeholder(dtype=tf.float32, shape=[input_node, fc_node1], name='Swap_weight1')
    Swap_bias1 = tf.compat.v1.placeholder(dtype=tf.float32, shape=[fc_node1], name='Swap_bias1')
    Swap_weight2 = tf.compat.v1.placeholder(dtype=tf.float32, shape=[fc_node1, fc_node2], name='Swap_weight2')
    Swap_bias2 = tf.compat.v1.placeholder(dtype=tf.float32, shape=[fc_node2], name='Swap_bias2')
    Swap_weight3 = tf.compat.v1.placeholder(dtype=tf.float32, shape=[fc_node2, output_node], name='Swap_weight3')
    Swap_bias3 = tf.compat.v1.placeholder(dtype=tf.float32, shape=[output_node], name='Swap_bias3')

    weight1 = tf.get_variable("weight1", [input_node, fc_node1], initializer=init)
    bias1 = tf.get_variable('bais1', [fc_node1], initializer=initb)
    weight2 = tf.get_variable('weight2', [fc_node1, fc_node2], initializer=init)
    bias2 = tf.get_variable('bias2', [fc_node2], initializer=initb)
    weight3 = tf.get_variable('weight3', [fc_node2, output_node], initializer=init)
    bias3 = tf.get_variable('bias3', [output_node], initializer=initb)

    sw1 = tf.assign(weight1, Swap_weight1)
    sw2 = tf.assign(weight2, Swap_weight2)
    sw3 = tf.assign(weight3, Swap_weight3)
    sb1 = tf.assign(bias1, Swap_bias1)
    sb2 = tf.assign(bias2, Swap_bias2)
    sb3 = tf.assign(bias3, Swap_bias3)

    hidden1 = tf.nn.relu(tf.matmul(x, weight1) + bias1)
    hidden2 = tf.nn.relu(tf.matmul(hidden1, weight2) + bias2)

    y = tf.matmul(hidden2, weight3) + bias3
    regularizer = tf.contrib.layers.l2_regularizer(regularization_rate)
    loss = regularizer(weight1) + regularizer(weight2)
    global_step = tf.Variable(0, trainable=False)
    losses = loss + tf.reduce_mean(tf.nn.sparse_softmax_cross_entropy_with_logits(logits=y, labels=tf.argmax(y_, 1)))
    learning_rate = tf.compat.v1.train.exponential_decay(0.8, global_step, mnist.train.num_examples / batch, 0.95)

    train_step = tf.compat.v1.train.GradientDescentOptimizer(learning_rate).minimize(losses, global_step=global_step)
    correct_prediction = tf.equal(tf.argmax(y, 1), tf.argmax(y_, 1))
    accuracy = tf.reduce_mean(tf.cast(correct_prediction, tf.float32))
    with tf.compat.v1.Session() as sess:
        tf.global_variables_initializer().run()
        test_feed = {x: mnist.test.images, y_: mnist.test.labels}

        for i in range(epoch):
            if i % 550 == 0:  # 因为batch=100 ,每迭代550次,就相当于完成了1次训练。总共训练30轮
                test_acc = sess.run(accuracy, feed_dict=test_feed)
                print("训练 %d 轮后,验证数据集的精度为: %g%%" % (i / 550, test_acc * 100))
                # print("当前学习效率为:%g"%(sess.run(learning_rate)))
                train_acc = 0
                for j in range(10):
                    XS, YS = mnist.train.next_batch(5500)
                    train_acc += sess.run(accuracy, feed_dict={x: XS, y_: YS})
                print("训练 %d 轮后,训练数据集的精度为: %g%%" % (i / 550, train_acc * 10))
                train_error.append(100 - train_acc * 10)
                test_error.append(100 - test_acc * 100)

            xs, ys = mnist.train.next_batch(batch)
            sess.run(train_step, feed_dict={x: xs, y_: ys})

            w1, w2, w3, b1, b2, b3 = sess.run([weight1, weight2, weight3, bias1, bias2, bias3])
            # print("befroe:",w1)
            exchange2(w1)
            # print("after:",w1)
            exchange2(w2)
            exchange2(w3)
            exchange1(b1)
            exchange1(b2)
            exchange1(b3)
            sess.run([sw1, sw2, sw3], feed_dict={Swap_weight1: w1, Swap_weight2: w2, Swap_weight3: w3})
            sess.run([sb1, sb2, sb3], feed_dict={Swap_bias1: b1, Swap_bias2: b2, Swap_bias3: b3})

        test_acc = sess.run(accuracy, feed_dict=test_feed)
        print("训练 %d 轮后,测试数据集的精度为: %g%%" % (epoch / 550, test_acc * 100))


def main(argv=None):
    mnist = input_data.read_data_sets("C:/Users/tang/Desktop/deeplearning/mnist数据集", one_hot=True)
    trains(mnist)
    xlable ='(FL='
    xlable+=str(FL)+' and round to '
    if round :
        xlable+='nearest '
    else :
        xlable+='Stochastic '

    xlable+=') Training epoch'
    plt.plot(range(0, epoch//550), train_error, label="train error")
    plt.plot(range(0, epoch//550), test_error, label='test error')
    plt.xlabel(xlable)
    plt.ylabel('Error (%)')
    plt.legend()
    plt.show()


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

这是我的垃圾笔记本跑的,快一个小时了。贴一个FL=8,最近邻舍入的运行结果

训练 0 轮后,验证数据集的精度为: 5.95%
训练 0 轮后,训练数据集的精度为: 6.53818%
训练 1 轮后,验证数据集的精度为: 90.46%
训练 1 轮后,训练数据集的精度为: 90.4982%
训练 2 轮后,验证数据集的精度为: 92.94%
训练 2 轮后,训练数据集的精度为: 93.1145%
......
训练 29 轮后,验证数据集的精度为: 97.41%
训练 29 轮后,训练数据集的精度为: 99.9436%
训练 30 轮后,测试数据集的精度为: 97.47%

图像大概这样:
在这里插入图片描述
这个结果跟论文中的图像基本吻合
训练集的误差0.05%,测试集误差2.53% ,比论文好也是理应的,因为我程序计算的中间过程全是32bit浮点数。
.
下面是8位小数随机舍入的结果:

训练 0 轮后,验证数据集的精度为: 13.98%
训练 0 轮后,训练数据集的精度为: 14.1473%
训练 1 轮后,验证数据集的精度为: 96.21%
训练 1 轮后,训练数据集的精度为: 96.5145%
训练 2 轮后,验证数据集的精度为: 97.08%
......
训练 29 轮后,验证数据集的精度为: 98.28%
训练 29 轮后,训练数据集的精度为: 99.9527%
训练 30 轮后,测试数据集的精度为: 98.3%

图像大概是这个样子:
在这里插入图片描述
.
.
.
下面是mnist数据集在CNN上的设计
CNN网络结果跟LeNet-5 模型类似
CNN结构:
含有两个卷积层,每个卷积层后跟一个max_pooling(池化)层
第一个卷积层是8个5x5的filter
第二个卷积层是16个5x5的filter
两个池化层都是2x2的步长也是2x2的采样
全连接层是128个结点,然后输出层采用softmax,结点个数为10
激活函数是:ReLU
采用学习效率梯度递减(最开始为0.1,衰减率是0.95,衰减速度是每个batch)
使用动量梯度下降算法(p=0.9)
L2正则化权重衰减率为0.0005

论文最终的误差是0.77%
在这里插入图片描述在这里插入图片描述
没有使用动量梯度,还是用随机梯度下降

import tensorflow as tf
from tensorflow.examples.tutorials.mnist import input_data
import numpy as np
batch = 100
image_size = 28
conv1_size = 5
conv1_deep = 16
conv2_size = 5
conv2_deep = 32
fc_node = 128
output_node = 10
regularization_rate = 0.0001
epoch = 40000


def trains(mnist):
    init = tf.truncated_normal_initializer(stddev=0.01)
    initb = tf.constant_initializer(0.0)
    x = tf.placeholder(tf.float32, [batch, image_size, image_size, 1], name='x-input')
    y_ = tf.placeholder(tf.float32, [None, output_node], name='y-input')
    # 第一层卷积
    weight1 = tf.get_variable("weight1", [conv1_size, conv1_size, 1, conv1_deep], initializer=init)
    bias1 = tf.get_variable("bias1", [conv1_deep], initializer=initb)
    conv1 = tf.nn.bias_add(tf.nn.conv2d(x, weight1, strides=[1, 1, 1, 1], padding="SAME"), bias1)
    conv1 = tf.nn.relu(conv1)
    pool1 = tf.nn.max_pool(conv1, ksize=[1, 2, 2, 1], strides=[1, 2, 2, 1], padding="SAME")
    # 第二层卷积
    weight2 = tf.get_variable("weight2", [conv2_size, conv2_size, conv1_deep, conv2_deep], initializer=init)
    bias2 = tf.get_variable('bias2', [conv2_deep], initializer=initb)
    conv2 = tf.nn.bias_add(tf.nn.conv2d(pool1, weight2, strides=[1, 1, 1, 1], padding="SAME"), bias2)
    conv2 = tf.nn.relu(conv2)
    pool2 = tf.nn.max_pool(conv2, ksize=[1, 2, 2, 1], strides=[1, 2, 2, 1], padding="SAME")
    #转换形状
    P_shape = pool2.get_shape().as_list()
    node = P_shape[1] * P_shape[2] * P_shape[3]
    fc_input1 = tf.reshape(pool2, [P_shape[0], node])

    # 全连接层
    weight3 = tf.get_variable("weight3", [node, fc_node], initializer=init)
    bias3 = tf.get_variable("bias3", [fc_node], initializer=initb)
    fc_output1 = tf.nn.relu(tf.matmul(fc_input1, weight3) + bias3)

    # 输出层
    weight4 = tf.get_variable("weight4", [fc_node, output_node], initializer=init)
    bias4 = tf.get_variable("bias4", [output_node], initializer=initb)
    y=tf.matmul(fc_output1, weight4) + bias4

    regularizer = tf.contrib.layers.l2_regularizer(regularization_rate)
    loss = regularizer(weight3)+regularizer(weight4)
    global_step = tf.Variable(0, trainable=False)
    losses = loss + tf.reduce_mean(tf.nn.sparse_softmax_cross_entropy_with_logits(logits=y, labels=tf.argmax(y_, 1)))
    learning_rate = tf.compat.v1.train.exponential_decay(0.1, global_step, mnist.train.num_examples / batch, 0.95)

    train_step = tf.compat.v1.train.GradientDescentOptimizer(learning_rate=learning_rate)\
        .minimize(losses,global_step=global_step)
    sum = tf.reduce_sum(tf.cast(tf.equal(tf.argmax(y, 1), tf.argmax(y_, 1)), dtype=tf.float32))
    with tf.compat.v1.Session() as sess:
        tf.global_variables_initializer().run()
        for i in range(epoch+1):
            if i % 1000 == 0:
                SUM=0
                for j in range(mnist.validation.num_examples//batch):
                    xs, ys = mnist.validation.next_batch(batch)
                    xs = np.reshape(xs, newshape=[batch, image_size, image_size, 1])
                    SUM+= sess.run(sum, feed_dict={x:xs,y_:ys})
                print("训练 %d 轮后,验证数据集的精度为: %g%%" % (i, SUM/mnist.validation.num_examples * 100))
                print("当前学习效率为:%g" % (sess.run(learning_rate)))

            if i % 5000 == 0:
                SUM=0
                for j in range(mnist.test.num_examples//batch):
                    xs, ys = mnist.train.next_batch(batch)
                    xs = np.reshape(xs, newshape=[batch, image_size, image_size, 1])
                    SUM += sess.run(sum, feed_dict={x: xs, y_: ys})
                print("训练 %d 轮后,测试数据集的精度为: %g%%" % (i, SUM/mnist.test.num_examples * 100,))

            xs, ys = mnist.train.next_batch(batch)
            xs = np.reshape(xs, newshape=[batch, image_size, image_size, 1])
            sess.run(train_step, feed_dict={x: xs, y_: ys})

def main(argv=None):
    mnist = input_data.read_data_sets("C:/Users/tang/Desktop/deeplearning/mnist数据集", one_hot=True)
    trains(mnist)


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

运行结果如下:

训练 0 轮后,验证数据集的精度为: 7.72%
当前学习效率为:0.1
训练 0 轮后,测试数据集的精度为: 8.47%
训练 1000 轮后,验证数据集的精度为: 89.78%
当前学习效率为:0.0910956
训练 2000 轮后,验证数据集的精度为: 98.16%
当前学习效率为:0.0829841
训练 3000 轮后,验证数据集的精度为: 98.48%
当前学习效率为:0.0755949
训练 4000 轮后,验证数据集的精度为: 98.72%
当前学习效率为:0.0688636
训练 5000 轮后,验证数据集的精度为: 98.86%
当前学习效率为:0.0627317
训练 5000 轮后,测试数据集的精度为: 98.86%
训练 6000 轮后,验证数据集的精度为: 98.9%
当前学习效率为:0.0571459
训练 7000 轮后,验证数据集的精度为: 99.02%
当前学习效率为:0.0520574
训练 8000 轮后,验证数据集的精度为: 98.7%
当前学习效率为:0.047422
训练 9000 轮后,验证数据集的精度为: 98.96%
当前学习效率为:0.0431993
训练 10000 轮后,验证数据集的精度为: 99%
当前学习效率为:0.0393527
训练 10000 轮后,测试数据集的精度为: 98.82%
训练 11000 轮后,验证数据集的精度为: 99.06%
当前学习效率为:0.0358486
训练 12000 轮后,验证数据集的精度为: 99.06%
当前学习效率为:0.0326565
训练 13000 轮后,验证数据集的精度为: 99.14%
当前学习效率为:0.0297486
训练 14000 轮后,验证数据集的精度为: 99.16%
当前学习效率为:0.0270997
训练 15000 轮后,验证数据集的精度为: 99.12%
当前学习效率为:0.0246866
训练 15000 轮后,测试数据集的精度为: 99.03%

可能由于优化不当,误差为0.97%。效果没有论文的好。运行时间过长。

发布了11 篇原创文章 · 获赞 14 · 访问量 1010

猜你喜欢

转载自blog.csdn.net/qq_41832757/article/details/102741855