简体   繁体   中英

Finding weights for conv2d layer in Tensorflow

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:

在此处输入图片说明

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.

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).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM