import torch
import torch.nn as nn
import torch
from torchsummary import summary
# from tensorboardX import summary
class 优快云_Tem(nn.Module):
def __init__(self, in_ch, out_ch):
super(优快云_Tem, self).__init__()
self.depth_conv = nn.Conv2d(
in_channels=in_ch,
out_channels=in_ch,
kernel_size=3,
stride=1,
padding=1,
groups=in_ch
)
self.point_conv = nn.Conv2d(
in_channels=in_ch,
out_channels=out_ch,
kernel_size=1,
stride=1,
padding=0,
groups=1
)
def forward(self, input):
out = self.depth_conv(input)
out = self.point_conv(out)
return out
conv = 优快云_Tem(16,64)
print(conv.depth_conv)
print(summary(conv,(16,1))
深度可分离卷积pytorch代码
于 2021-03-30 22:11:04 首次发布
该博客介绍了如何使用PyTorch构建一个名为优快云_Tem的神经网络模块,该模块包含深度卷积和点卷积两部分。通过`nn.Conv2d`定义了两个卷积层,分别用于不同功能。在前向传播函数中,首先应用深度卷积,然后通过点卷积得到输出。博客还展示了如何打印网络结构并使用`torchsummary`库进行模型概览。
部署运行你感兴趣的模型镜像
您可能感兴趣的与本文相关的镜像
PyTorch 2.5
PyTorch
Cuda
PyTorch 是一个开源的 Python 机器学习库,基于 Torch 库,底层由 C++ 实现,应用于人工智能领域,如计算机视觉和自然语言处理
2044

被折叠的 条评论
为什么被折叠?



