神经网络之LeNet网络结构(Python+TensorFlow)
来源:互联网 发布:免费英语网络课程 编辑:程序博客网 时间:2024/05/19 03:19
# -*- coding:utf-8 -*-## LeNet modelimport tensorflow as tfimport numpy as npdef get_weight(shape, name): return tf.Variable(tf.truncated_normal(shape, stddev=0.1), name=name)def get_bias(shape, name): return tf.Variable(tf.constant(0.0, shape=shape), name=name)def conv_layer(x, ks, out_units, name): with tf.variable_scope(name): in_units = x.get_shape().as_list()[-1] filt = get_weight([ks,ks,in_units,out_units], name='weight') bias = get_bias([out_units], name='bias') out = tf.nn.relu(tf.nn.bias_add(tf.nn.conv2d(x, filt, [1,1,1,1], padding='VALID'), bias)) return outdef fc_layer(x, out_units, name): with tf.variable_scope(name): in_units = np.prod(x.get_shape().as_list()[1:]) x_flat = tf.reshape(x, [-1, in_units]) weight = get_weight([in_units,out_units], name='weight') biases = get_bias([out_units], name='bias') out = tf.nn.bias_add(tf.matmul(x_flat, weight), biases) return outdef lenet(images, num_class=10, keep_prob=0.5): # conv1 conv1 = conv_layer(images, ks=5, out_units=32, name='C1') # pool2 pool2 = tf.nn.max_pool(conv1, ksize=[1,2,2,1], strides=[1,2,2,1], padding='SAME', name='S2') # conv3 conv3 = conv_layer(pool2, ks=5, out_units=64, name='C3') # pool4 pool4 = tf.nn.max_pool(conv3, ksize=[1,2,2,1], strides=[1,2,2,1], padding='SAME', name='S4') # conv5 conv5 = conv_layer(pool4, ks=5, out_units=120, name='C5') # fc6 fc6 = fc_layer(conv5, out_units=84, name='F6') fc6_drop = tf.nn.dropout(fc6, keep_prob) # fc7 out = fc_layer(fc6_drop, out_units=num_class, name='F7') return out
阅读全文
0 0
- 神经网络之LeNet网络结构(Python+TensorFlow)
- LeNet -5 卷积神经网络的网络结构
- Tensorflow实例:(卷积神经网络)LeNet-5模型
- 神经网络之LeNet结构分析及参数详解
- Lenet-5网络结构
- 神经网络之AlexNet模型的实现(Python+TensorFlow)
- 神经网络之VGGNet模型的实现(Python+TensorFlow)
- 神经网络之Inception模型的实现(Python+TensorFlow)
- 神经网络之ResNet模型的实现(Python+TensorFlow)
- 卷积神经网络的网络结构——以LeNet-5为例
- 卷积神经网络的网络结构——以LeNet-5为例
- 卷积神经网络的网络结构——以LeNet-5为例
- 卷积神经网络的网络结构——以LeNet-5为例
- 卷积神经网络的网络结构——以LeNet-5为例
- LeNet的详细网络结构
- LeNet-5网络结构解析
- LeNet的详细网络结构
- 深度学习(DL)与卷积神经网络(CNN)学习笔记随笔-03-基于Python的LeNet之LR(转)
- 课时3 命令行BASH的基本操作
- JDK安装和环境变量配置及问题
- linux系统禁ping
- 模拟页面模板引擎
- bzoj1003 物流运输
- 神经网络之LeNet网络结构(Python+TensorFlow)
- Eclipse下安装Scala插件
- 程序的编译的过程
- 7/12作业:接口
- You cannot start a load for a destroyed activity错误处理
- python、opencv以及第三方库的安装
- 数字化原理
- 一,二维数组的相关问题
- Android自定义属性实现显示两行文字的button