tensorflow 中 convolution2d 和 conv2d 在用法上的区别
difference between convolution2d and conv2d in tensorflow in terms of ussage
在用于二维卷积的 TensorFlow 中,我们有:
tf.nn.conv2d(input, filter, strides, padding, use_cudnn_on_gpu=None,
data_format=None, name=None)
和
tf.contrib.layers.convolution2d(*args, **kwargs)
- 我不确定差异?
- 我知道如果我想使用特殊的过滤器,我应该使用第一个,对吗?但还有什么?尤其是输出?
谢谢
tf.nn.conv2d(...)
是 TensorFlow 提供的核心低级卷积功能。 tf.contrib.layers.conv2d(...)
是围绕 core-TensorFlow 构建的更高级别 API 的一部分。
请注意,在当前的 TensorFlow 版本中,部分层现在也在核心中,例如tf.layers.conv2d
.
区别很简单,tf.nn.conv2d
是一个 op,它做卷积,没有别的。 tf.layers.conv2d
做得更多,例如它还为内核和偏差等创建变量。
查看使用 Tensorflow 核心的 CNN 上的 Tensorflow 教程 (here)。对于低级API,卷积层是这样创建的:
def conv2d(x, W):
return tf.nn.conv2d(x, W, strides=[1, 1, 1, 1], padding='SAME')
W_conv1 = weight_variable([5, 5, 1, 32])
b_conv1 = bias_variable([32])
h_conv1 = tf.nn.relu(conv2d(x_image, W_conv1) + b_conv1)
将其与 CNN 的 TF 层教程 (here) 进行比较。使用 TF Layers 卷积层是这样创建的:
conv1 = tf.layers.conv2d(
inputs=input_layer,
filters=32,
kernel_size=[5, 5],
padding="same",
activation=tf.nn.relu)
在不知道您的用例的情况下:您很可能想使用 tf.layers.conv2d
。
在 Tensorflow 2.x 中 tf.keras.layers.Conv2D
和 tf.keras.layers.Convolution2D
没有区别。
Here's the link for the illustration
在 tensorflow 2.x 中,keras
是 tensorflow
中的 API
在用于二维卷积的 TensorFlow 中,我们有:
tf.nn.conv2d(input, filter, strides, padding, use_cudnn_on_gpu=None,
data_format=None, name=None)
和
tf.contrib.layers.convolution2d(*args, **kwargs)
- 我不确定差异?
- 我知道如果我想使用特殊的过滤器,我应该使用第一个,对吗?但还有什么?尤其是输出?
谢谢
tf.nn.conv2d(...)
是 TensorFlow 提供的核心低级卷积功能。 tf.contrib.layers.conv2d(...)
是围绕 core-TensorFlow 构建的更高级别 API 的一部分。
请注意,在当前的 TensorFlow 版本中,部分层现在也在核心中,例如tf.layers.conv2d
.
区别很简单,tf.nn.conv2d
是一个 op,它做卷积,没有别的。 tf.layers.conv2d
做得更多,例如它还为内核和偏差等创建变量。
查看使用 Tensorflow 核心的 CNN 上的 Tensorflow 教程 (here)。对于低级API,卷积层是这样创建的:
def conv2d(x, W):
return tf.nn.conv2d(x, W, strides=[1, 1, 1, 1], padding='SAME')
W_conv1 = weight_variable([5, 5, 1, 32])
b_conv1 = bias_variable([32])
h_conv1 = tf.nn.relu(conv2d(x_image, W_conv1) + b_conv1)
将其与 CNN 的 TF 层教程 (here) 进行比较。使用 TF Layers 卷积层是这样创建的:
conv1 = tf.layers.conv2d(
inputs=input_layer,
filters=32,
kernel_size=[5, 5],
padding="same",
activation=tf.nn.relu)
在不知道您的用例的情况下:您很可能想使用 tf.layers.conv2d
。
在 Tensorflow 2.x 中 tf.keras.layers.Conv2D
和 tf.keras.layers.Convolution2D
没有区别。
Here's the link for the illustration
在 tensorflow 2.x 中,keras
是 tensorflow