0

I am pretty confused when it comes to the shape of a convolutional layer in tensorflow.

kernels = tf.get_collection(tf.GraphKeys.GLOBAL_VARIABLES, "conv1d(_.)?/kernel:0")

Running this line returns me a kernel with 4 dimensions and a bias. I expected that the kernel would return me [filter_width, filter_height, filter_number] and a 2D matrix with weights. Instead i have a fourth dimensions and no weights at all.

Maybe I should not interchange dense with convolutional layers in my mind. However most of the explanations I find on the internet stay on a simple level without going into the details of tensorflows model.

So most important for me would be getting the interconnected weights of the edges between the layers. Like seen on this picture:

enter image description here

This link regards to my problem: Something I want from Tensorflow

I hope someone can follow my trouble in understanding, otherwise do not hesitate adding comments.

Harald
  • 526
  • 4
  • 26
  • Kernels are 4 dimensional, those area the weights you want. What exactly is the problem? – Dr. Snoopy Jul 13 '18 at 12:59
  • I just dont understand how the image values between 2 layers are accumulated and what the usage of the 4th dimension of a kernel is. – Harald Jul 13 '18 at 13:34
  • I don't know what you mean "accumulated". Filters/kernels always have 4 dimensions, which are (width, height, filter_nr, channels). You are just forgetting about channels. – Dr. Snoopy Jul 13 '18 at 13:36
  • But my image has only one Channel. However the Kernel has suddendly 16 and more? Also I updated my question with a picture, so its simple to get, what is meant with accumulated. Where are those -0.55 and 0.1 weights? – Harald Jul 13 '18 at 13:40
  • Those weights are for a fully connected (dense) layer, not for a convolutional layer (which is what Conv2D is). – Dr. Snoopy Jul 13 '18 at 13:52
  • So there are no weights or something similar to determine if a filter is useful or not? Well pls poste your last comment as anwser, i will accept it. – Harald Jul 13 '18 at 13:59

1 Answers1

1

Filters/kernels always have 4 dimensions, which are (width, height, filter_nr, channels). Channels equals to the number of channels in the input image, but for later layers in the network it may be different.

The weights you are asking are for a fully connected (dense) layer, not for a convolutional layer (which is what Conv2D is).

Dr. Snoopy
  • 55,122
  • 7
  • 121
  • 140