Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
修改概述: 重构CNN_tensorflow.py,从TF1迁移至TF2 Keras API,引入残差网络和现代训练策略,将MNIST识别准确率从约99%提升至99.53%
修改的详细描述
tf.placeholder、tf.Session、tf.nn.dropout等TF1风格代码全部重构为TF2 Keras API(tf.keras.Model、tf.keras.layers),消除废弃API警告,代码从约250行精简至约230行,可读性和可维护性显著提升。max_epoch和keep_prob_rate,但定义时为大写MAX_EPOCH和KEEP_PROB_RATE,运行会报NameError;优化器引用了未定义的learning_rate变量(应为LEARNING_RATE)。he_normal)替代原来的截断正态分布(stddev=0.1),更适配ReLU激活函数,加速收敛。is_training为placeholder用Pythonif判断实际未生效。改进版使用Keras内置层实现训练时自动生效的轻度增强:随机旋转±9°、平移±5%、缩放±3%(不做水平翻转,避免6和9混淆)。经过了什么样的测试?
运行效果
各数字识别准确率: