in Education by
What is the difference between 1D, 2D and 3D convolutions in CNN? Please explain with examples. Select the correct answer from above options

1 Answer

0 votes
by
 
Best answer
1D convolutions - Only 1-direction to calculate conv input = [W], filter = [k], output = [W] input = [1,1,1,1,1], filter = [0.25,0.5,0.25], output = [1,1,1,1,1] output-shape is 1D array Ex-graph smoothing Ex - import tensorflow as tf import numpy as np ses = tf.Session() ones_1d = np.ones(5) weight_1d = np.ones(3) stride_1d = 1 in_1d = tf.constant(ones_1d, dtype=tf.float32) fil_1d = tf.constant(weight_1d, dtype=tf.float32) in_w = int(in_1d.shape[0]) fil_w = int(fil_1d.shape[0]) input_1d = tf.reshape(in_1d, [1, in_w, 1]) kernel_1d = tf.reshape(fil_1d, [fil_w, 1, 1]) result_1d = tf.squeeze(tf.nn.conv1d(input_1d, kernel_1d, stride_1d, padding='SAME')) print ses.run(result_1d) 2D convolution - 2-directions (x,y) to calculate conv input = [W, H], filter = [k,k] output = [W,H] output-shape is a 2D Matrix Ex-Sobel Egde Fllter Ex - ones_2d = np.ones((5,5)) weight_2d = np.ones((3,3)) stride_2d = [1, 1, 1, 1] in_2d = tf.constant(ones_2d, dtype=tf.float32) fil_2d = tf.constant(weight_2d, dtype=tf.float32) in_w = int(in_2d.shape[0]) in_h= int(in_2d.shape[1]) fil_w = int(fil_2d.shape[0]) fil_h = int(fil_2d.shape[1]) input_2d = tf.reshape(in_2d, [1, in_he, in_w, 1]) kernel_2d = tf.reshape(fil_2d, [fil_h, fil_w, 1, 1]) result_2d = tf.squeeze(tf.nn.conv2d(input_2d, kernel_2d, strides=stride_2d, padding='SAME')) print ses.run(result_2d) 3D convolution - 3-direction (x,y,z) to calcuate conv input = [W,H,L], filter = [k,k,d] output = [W,H,M] output-shape is 3D Volume d < L is important! for making volume output Ex - ones_3d = np.ones((5,5,5)) weight_3d = np.ones((3,3,3)) stride_3d = [1, 1, 1, 1, 1] in_3d = tf.constant(ones_3d, dtype=tf.float32) fil_3d = tf.constant(weight_3d, dtype=tf.float32) in_w = int(in_3d.shape[0]) in_h= int(in_3d.shape[1]) in_d= int(in_3d.shape[2]) fil_w = int(fil_3d.shape[0]) fil_h = int(fil_3d.shape[1]) fil_d = int(fil_3d.shape[2]) input_3d = tf.reshape(in_3d, [1, in_d, in_h, in_d, 1]) kernel_3d = tf.reshape(filter_3d, [fil_d, filter_h, fil_w, 1, 1]) result_3d = tf.squeeze(tf.nn.conv3d(input_3d, kernel_3d, strides=stride_3d, padding='SAME')) print ses.run(result_3d) Hope this helps! If you want to know more about the neural network visit this Neural Network Tutorial.

Related questions

0 votes
    How is the convolution operation carried out when multiple channels are present at the input layer? (e.g. RGB ... over several regions? Select the correct answer from above options...
asked Jan 29, 2022 in Education by JackTerrance
0 votes
    I'm learning the difference between the various machine learning algorithms. I understand that the implementations of ... for that? Select the correct answer from above options...
asked Jan 25, 2022 in Education by JackTerrance
0 votes
    I was wondering if you creative minds out there could think of some situations or applications in the web environment ... AI in games. Select the correct answer from above options...
asked Jan 26, 2022 in Education by JackTerrance
0 votes
    I have a simple NN model for detecting hand-written digits from a 28x28px image written in python using Keras: ... that actually means? Select the correct answer from above options...
asked Jan 28, 2022 in Education by JackTerrance
0 votes
    I am looking for an open source neural network library. So far, I have looked at FANN, WEKA, and OpenNN. Are the ... , and ease of use. Select the correct answer from above options...
asked Feb 8, 2022 in Education by JackTerrance
0 votes
    What are the steps to use shape for a 1D array, 2D array and 3D/ND array respectively in NumPy?...
asked Apr 24, 2021 in Technology by JackTerrance
0 votes
    I read a few books and articles about Convolutional neural network, it seems I understand the concept but I don ... please help thanks. Select the correct answer from above options...
asked Jan 30, 2022 in Education by JackTerrance
0 votes
    Neural Networks Algorithms are inspired from the structure and functioning of the Human Biological Neuron. A. True B. False...
asked Dec 26, 2022 in Technology by JackTerrance
0 votes
    Neural Networks Algorithms are inspired from the structure and functioning of the Human Biological Neuron. A. True B. False...
asked Nov 13, 2022 in Education by JackTerrance
0 votes
    Recurrent Neural Networks are best suited for Text Processing. A. True B. False...
asked Dec 26, 2022 in Technology by JackTerrance
0 votes
    In the MNIST beginner tutorial, there is the statement accuracy = tf.reduce_mean(tf.cast(correct_prediction, "float")) tf ... (x,1)? Select the correct answer from above options...
asked Feb 8, 2022 in Education by JackTerrance
0 votes
    What is the difference between informed and uninformed searches? Can you explain this with some examples? Select the correct answer from above options...
asked Feb 4, 2022 in Education by JackTerrance
0 votes
    I'm Working on document classification tasks in java. Both algorithms came highly recommended, what are the ... Processing tasks? Select the correct answer from above options...
asked Feb 2, 2022 in Education by JackTerrance
0 votes
    From what I've read so far they seem very similar. Differential evolution uses floating point numbers instead, and ... of both. Select the correct answer from above options...
asked Jan 30, 2022 in Education by JackTerrance
0 votes
    I have trouble understanding the difference (if there is one) between roc_auc_score() and auc() in scikit-learn. I ... out why. Thanks! Select the correct answer from above options...
asked Jan 29, 2022 in Education by JackTerrance
...