1 Star 0 Fork 3

黎陌啊/ConvLSTM-PyTorch

forked from lhx/ConvLSTM-PyTorch 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
utils.py 1.67 KB
一键复制 编辑 原始数据 按行查看 历史
jhhuang96 提交于 2020-03-09 16:16 . reconstruction
from torch import nn
from collections import OrderedDict
def make_layers(block):
layers = []
for layer_name, v in block.items():
if 'pool' in layer_name:
layer = nn.MaxPool2d(kernel_size=v[0], stride=v[1], padding=v[2])
layers.append((layer_name, layer))
elif 'deconv' in layer_name:
transposeConv2d = nn.ConvTranspose2d(in_channels=v[0],
out_channels=v[1],
kernel_size=v[2],
stride=v[3],
padding=v[4])
layers.append((layer_name, transposeConv2d))
if 'relu' in layer_name:
layers.append(('relu_' + layer_name, nn.ReLU(inplace=True)))
elif 'leaky' in layer_name:
layers.append(('leaky_' + layer_name,
nn.LeakyReLU(negative_slope=0.2, inplace=True)))
elif 'conv' in layer_name:
conv2d = nn.Conv2d(in_channels=v[0],
out_channels=v[1],
kernel_size=v[2],
stride=v[3],
padding=v[4])
layers.append((layer_name, conv2d))
if 'relu' in layer_name:
layers.append(('relu_' + layer_name, nn.ReLU(inplace=True)))
elif 'leaky' in layer_name:
layers.append(('leaky_' + layer_name,
nn.LeakyReLU(negative_slope=0.2, inplace=True)))
else:
raise NotImplementedError
return nn.Sequential(OrderedDict(layers))
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/let_free/ConvLSTM-PyTorch.git
git@gitee.com:let_free/ConvLSTM-PyTorch.git
let_free
ConvLSTM-PyTorch
ConvLSTM-PyTorch
master

搜索帮助