python - 如何在卷积自动编码器中使用 pytorch 库中的 MaxUnpool1d?
问题描述
我想在 python 中使用 Pytorch 库构建一个卷积自动编码器。所有示例都没有 MaxUnpool1d。
我要构建的架构应该是这样的:
class autoencoder(nn.Module):
def __init__(self):
self.encoder = nn.Sequential(
nn.Conv1d(in_channels=1, out_channels=64 ,kernel_size=16 , stride=3),
nn.ReLU(True),
nn.MaxPool1d(4),
nn.Conv1d(64, 128 ,8, 3),
nn.ReLU(True),
nn.MaxPool1d(4),
)
self.decoder = nn.Sequential(
nn.MaxUnpool1d(4),
nn.ConvTranspose1d(in_channels =128, out_channels =64 , kernel_size =8, stride= 3),
nn.ReLU(True),
nn.MaxUnpool1d(4),
nn.ConvTranspose1d(64, 1 ,16, 3),
nn.Tanh()
)
def forward(self, x):
x = self.encoder(x)
x = self.decoder(x)
return x
为了让它工作,我应该为 MaxUnpool1d 层提供索引。如何在当前架构中使用它并使输入大小等于输出?
谢谢。
解决方案
推荐阅读
- android - onActivityResult() 从未调用过
- phoenix - Live View 应用程序在全新安装后不断重新加载
- rust - 如何转换选项中的内部值?
- react-native - 如何在 React Native 中更改 TextInput 光标位置?
- javascript - 从 router.js 异步调用 vuex 操作有多好?
- css - 按钮上的 chrome 中的粘滞悬停状态
- r - 带有 by 的 unique.data.table 的行为是否类似于带有 .keep_all = TRUE 的 dplyr::distinct?
- android - Android Studio Preview 4.1 Canary 10 中的构建错误
- webpack - regeneratorRuntime 未定义 Gulp + Webpack + Babel
- javascript - 带有外部指纹扫描仪的 React-Native 生物识别(secugen,futronics)