1.0版本中的卷积函数:tf.layers.conv2d
conv2d(
inputs,
filters,
kernel_size,
strides=(1, 1),
padding='valid',
data_format='channels_last',
dilation_rate=(1, 1),
activation=None,
use_bias=True,
kernel_initializer=None,
bias_initializer=tf.zeros_initializer(),
kernel_regularizer=None,
bias_regularizer=None,
activity_regularizer=None,
trainable=True,
name=None,
reuse=None
)
定义在tensorflow/python/layers/convolutional.py.
参数多了很多,但实际用起来,却更简单。
data_format: 输入数据格式,默认为channels_last ,即 (batch, height, width, channels),也可以设置为channels_first 对应 (batch, channels, height, width).
dilation_rate: 微步长卷积,这个比较复杂一些,请百度.
activation: 激活函数.
conv1=tf.layers.conv2d(
inputs=x,
filters=32,
kernel_size=5,
padding="same",
activation=tf.nn.relu,
kernel_initializer=tf.TruncatedNormal(stddev=0.01))
更复杂一些的
conv1 = tf.layers.conv2d(batch_images,
filters=64,
kernel_size=7,
strides=2,
activation=tf.nn.relu,
kernel_initializer=tf.TruncatedNormal(stddev=0.01)
bias_initializer=tf.Constant(0.1),
kernel_regularizer=tf.contrib.layers.l2_regularizer(0.003),
bias_regularizer=tf.contrib.layers.l2_regularizer(0.003),
name='conv1')