部分堆叠张量

发布于 2025-01-21 12:57:16 字数 173 浏览 2 评论 0原文

我在形状的pytorch中有一些卷积层的输出,其中b是我的批次,c是我的频道,h是功能。我想将它们堆叠成一个完全连接的图层,而不会更改批处理,以便它们处于形状[B,C*H]。我该怎么做?

I have some output from a convolutional layer in PyTorch of the shape [b,c,h] where b is my batches, c is my channels, and h is the features. I want to stack these to feed into a fully-connected layer without changing the batches, so that they are in the shape [b, c*h]. How can I do this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

南巷近海 2025-01-28 12:57:16

似乎简单的重塑或视图应该有效:

input.shape # [b,c,h]

reshaped = input.view(input.shape[0],-1) # [b,c*h]

Seems like a simple reshape or view should work:

input.shape # [b,c,h]

reshaped = input.view(input.shape[0],-1) # [b,c*h]
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文