本文链接:https://blog.csdn.net/weixin_44633882/article/details/89211865
简单了解一下tensorflow中tf.nn,tf.layers,tf.contrib三个模块。
展示个conv2d的接口:
tf.nn.conv2d(
input,
filter,
strides,
padding,
use_cudnn_on_gpu=True,
data_format='NHWC',
dilations=[1, 1, 1, 1],
name=None
)
同样,也给一个Conv2D的接口:
是不是这个形状很好看啊!可以看到,相较于tf.nn.conv2d()参数变多了。我比较在意的是:激活函数、kernel,bias的初始化和正则化,以及trainable都可以作为参数了。更加方便了!但我自己一般使用slim。
__init__(
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,
kernel_constraint=None,
bias_constraint=None,
trainable=True,
name=None,
**kwargs
)
tf.contrib.layers.conv2d(
inputs,
num_outputs,
kernel_size,
stride=1,
padding='SAME',
data_format=None,
rate=1,
activation_fn=tf.nn.relu,
normalizer_fn=None,
normalizer_params=None,
weights_initializer=initializers.xavier_initializer(),
weights_regularizer=None,
biases_initializer=tf.zeros_initializer(),
biases_regularizer=None,
reuse=None,
variables_collections=None,
outputs_collections=None,
trainable=True,
scope=None
)
参考:
https://tensorflow.google.cn/api_docs/python/tf
https://blog.csdn.net/u014365862/article/details/77833481