cs231n-2017-assignments2-TensorFlow.ipynb 心得体会
2017-07-21 23:42
405 查看
新手菜鸟级别,大神请绕道
今天较好的完成了cs231n-2017-assignments2-TensorFlow.ipynb中的最后一个部分:构建一个model对cifar数据集进行训练,今天的精度在train上达到0.98,在val上达到0.82,明天继续进行优化。
具体代码见TensorFlow.ipynb
以下仅贴出model:
心得体会:
1.模型很小时,即使是在train时,也很容易过拟合:几个epoch之后train_acc开始下降
2.模型很大时,为解决过拟合问题,在dense层加入了dropout,在loss中加入了regularization
3.没有batchnorm时,val_acc只能勉强到0.7,加入batchnorm后,直接到了0.8。这里要注意conv后接spatial batchnorm;而dense后接vanilla batchnorm
4.经常要计算conv的输出size,较为麻烦,编了个python的小程序,还挺方便
5.遇到问题,多查tensorflow官网
今天较好的完成了cs231n-2017-assignments2-TensorFlow.ipynb中的最后一个部分:构建一个model对cifar数据集进行训练,今天的精度在train上达到0.98,在val上达到0.82,明天继续进行优化。
具体代码见TensorFlow.ipynb
以下仅贴出model:
def my_model(X,y,is_training): # [conv-relu-conv-relu-pool] out=14x14 conv1 = tf.layers.conv2d(X,128,kernel_size=[3,3],strides=(1,1),activation=tf.nn.relu) ba1 = tf.layers.batch_normalization(conv1,training=is_training) conv2 = tf.layers.conv2d(ba1,256,[3,3],activation=tf.nn.relu) ba2 = tf.layers.batch_normalization(conv2,training=is_training) pool1 = tf.layers.max_pooling2d(ba2,pool_size=[2,2],strides=2) #[conv-relu-conv-relu-pool] out=5x5 conv3 = tf.layers.conv2d(pool1,512,[3,3],activation=tf.nn.relu) ba3 = tf.layers.batch_normalization(conv3,training=is_training) conv4 = tf.layers.conv2d(ba3,256,[3,3],activation=tf.nn.relu) ba4 = tf.layers.batch_normalization(conv4,training=is_training) pool2 = tf.layers.max_pooling2d(ba4,pool_size=[2,2],strides=2) #[dense-relu]x2 layer pool2_flat = tf.reshape(pool2,[-1,5*5*256]) dense1 =tf.layers.dense(pool2_flat,units=512,activation=tf.nn.relu) ba5 = tf.layers.batch_normalization(dense1,center=False,scale=False,training=is_training) dropout1 = tf.layers.dropout(ba5,training=is_training) dense2 = tf.layers.dense(dropout1,units=128,activation=tf.nn.relu) ba6 = tf.layers.batch_normalization(dense2,center=False,scale=False,training=is_training) dropout2 = tf.layers.dropout(ba6,training=is_training) #logit out logits = tf.layers.dense(dropout2,units=10) return logits
tf.reset_default_graph() X = tf.placeholder(tf.float32, [None, 32, 32, 3]) y = tf.placeholder(tf.int64, [None]) is_training = tf.placeholder(tf.bool) y_out = my_model(X,y,is_training) total_loss= tf.losses.softmax_cross_entropy(tf.one_hot(y,10),y_out)+tf.losses.get_regularization_loss() mean_loss = tf.reduce_mean(total_loss) optimizer = tf.train.RMSPropOptimizer(1e-3,decay=0.90,momentum=0.1) # batch normalization in tensorflow requires this extra dependency extra_update_ops = tf.get_collection(tf.GraphKeys.UPDATE_OPS) with tf.control_dependencies(extra_update_ops): train_step = optimizer.minimize(mean_loss)
心得体会:
1.模型很小时,即使是在train时,也很容易过拟合:几个epoch之后train_acc开始下降
2.模型很大时,为解决过拟合问题,在dense层加入了dropout,在loss中加入了regularization
3.没有batchnorm时,val_acc只能勉强到0.7,加入batchnorm后,直接到了0.8。这里要注意conv后接spatial batchnorm;而dense后接vanilla batchnorm
4.经常要计算conv的输出size,较为麻烦,编了个python的小程序,还挺方便
5.遇到问题,多查tensorflow官网
相关文章推荐
- cs231n-2017-assignments2-TensorFlow.ipynb 数据分析
- cs231n-2017-assignments2-TensorFlow.ipynb 自动调参
- 2017实习心得体会以及自己的小目标
- 2017Android校招心得体会
- 项目管理心得:一个项目经理的个人体会、经验总结
- 项目管理心得:一个项目经理的个人体会、经验总结
- 关于软件设计的一点心得体会
- 黑马程序员—18—java基础:有关IO流的学习笔记和学习心得体会
- 在Linux下串口信息的读取有了一点心得体会
- 如何查找技术资料----我的一点心得体会
- 【面试心得】2017CVTE春招面试笔试心得(失败的体会)
- 武汉鼎师科技笔试面试心得体会
- 心得体会
- 如何将ipynb转换为html,md,pdf等格式
- 项目改造过程与心得体会-2-数据库与Power Designer工具使用
- 01-learning-lenet.ipynb
- 项目管理心得:一个项目经理的个人体会、经验总结(转)
- 18号心得体会
- 12.12心得体会
- 公司项目须知和自己在工作上的心得体会