Difference between convolution2d and conv2d in tensor flow in terms of ussage

In TensorFlow for two-dimensional convolution we have:

tf.nn.conv2d(input, filter, strides, padding, use_cudnn_on_gpu=None,
             data_format=None, name=None) 

and

tf.contrib.layers.convolution2d(*args, **kwargs)
  • I'm not sure about the differences?
  • I know that I should use the first if I want to use a special filter, right? But what else? Especially about the conclusion?

thank

+4
source share
1 answer

tf.nn.conv2d(...)is the basic low-level convolution function provided by TensorFlow. tf.contrib.layers.conv2d(...)is part of building a higher-level API around the core of TensorFlow.

Note that in current versions of TensorFlow, parts of the layers are now also in the kernel. tf.layers.conv2d.

, tf.nn.conv2d - op, , . tf.layers.conv2d , . .

Tensorflow CNN, ​​Tensorflow (). 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)

TF Layers CNN (). TF :

conv1 = tf.layers.conv2d(
  inputs=input_layer,
  filters=32,
  kernel_size=[5, 5],
  padding="same",
  activation=tf.nn.relu)

: , tf.layers.conv2d.

+11

Source: https://habr.com/ru/post/1675516/


All Articles