简体   繁体   English

在Tensorflow中查找conv2d层的权重

[英]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. 运行这条线会返回一个具有4维和偏差的内核。 I expected that the kernel would return me [filter_width, filter_height, filter_number] and a 2D matrix with weights. 我期望内核会返回我[filter_width,filter_height,filter_number]和带有权重的2D矩阵。 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. 但是,我在互联网上找到的大多数解释都停留在一个简单的水平上,而无需深入研究tensorflows模型的细节。

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 此链接涉及我的问题: 我想从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). 过滤器/内核始终具有4个维度,即(宽度,高度,filter_nr,通道)。 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). 您要求的权重是针对完全连接的(密集)层,而不是卷积层(Conv2D是卷积层)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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