原文链接: TensorFlow 使用 slim 模块搭建复杂网络
上一篇: scrapy 代理使用
下一篇: TensorFlow infogan 生成 mnist 数据集
参考
https://blog.csdn.net/guvcolie/article/details/77686555
https://www.cnblogs.com/zyly/p/9146787.html
引入模块
import tensorflow.contrib.slim as slim
简化模型搭建
input = ...
with tf.name_scope('conv1_1') as scope:
kernel = tf.Variable(tf.truncated_normal([3, 3, 64, 128], dtype=tf.float32,
stddev=1e-1), name='weights')
conv = tf.nn.conv2d(input, kernel, [1, 1, 1, 1], padding='SAME')
biases = tf.Variable(tf.constant(0.0, shape=[128], dtype=tf.float32),
trainable=True, name='biases')
bias = tf.nn.bias_add(conv, biases)
conv1 = tf.nn.relu(bias, name=scope)
net = slim.conv2d(input, 128, [3, 3], scope='conv1_1')
TF-Slim提供了标准接口用于组建神经网络,包括:
Layer | TF-Slim |
---|---|
BiasAdd | slim.bias_add |
BatchNorm | slim.batch_norm |
Conv2d | slim.conv2d |
Conv2dInPlane | slim.conv2d_in_plane |
Conv2dTranspose (Deconv) | slim.conv2d_transpose |
FullyConnected | slim.fully_connected |
AvgPool2D | slim.avg_pool2d |
Dropout |