如何con绕重新连接输出和输入图像的原始大小?
我有17个类的图像数据集。某些类别的大小有很大差异,例如。一个类的图像平均为250x200,另一类25x25中的图像。 我的想法是将验证的RESNET18和原始图像尺寸的输出进行计算,因为我认为这是分类的宝贵信息。
要更具体 - 我想使用resnet18,但是到最后一层 (fc):线性(in_features = 512,out_features = 17,bias = true) 我也想添加图像。形状对于更好的分类可能很重要。
这是解决此类问题的合理解决方案吗?是否有一种方法可以在Pytorch中进行?
I have image dataset with 17 classes. There is a significant differ in sizes of some classes eg. images in one class are on average 250x200 and in the other class 25x25.
My idea was to concat output of pretrained resnet18 and original image size, because I think it's a valuable information for classification.
To be more specific - I would like to use resnet18 but to the last layer which is
(fc): Linear(in_features=512, out_features=17, bias=True)
I would like to add also Image.Shape which might be important for better classification.
Is this a reasonable solution for this kind of problem and is there a way to do it in PyTorch?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我想您想使用自适应池层产生的嵌入以具有固定的输出尺寸。首先,您需要摆脱最后的线性层(请参阅这篇文章):
然后,您可以获取嵌入式并使用pytorch.cat进行串联:
I guess you want to use the embedding that are produced by the Adaptive Pooling layer to have a fixed output size. First you need to get rid of the last linear layer (see this post):
Then you can get the embeddings and use pytorch.cat for concatenation: