Record study record life
大创第十二次汇报
大创第十二次汇报

大创第十二次汇报

通过代码实现dncnns去噪算法,在电磁信号一维的使用

File name : 第十二次汇报.pdf

import torch.nn as nn
from torchsummary import summary

class DnCNN(nn.Module):
    def __init__(self, channels):
        super(DnCNN, self).__init__()
        kernel_size =25
        padding =12
        features =32
        num_of_layers = 17
        layers = []
        layers.append(nn.Conv1d(in_channels=channels, out_channels=features,
                                kernel_size=kernel_size, padding=padding, bias=False))
        layers.append(nn.ReLU(inplace=True))
        for _ in range(num_of_layers - 2):
            layers.append(nn.Conv1d(in_channels=features, out_channels=features,
                                    kernel_size=kernel_size, padding=padding, bias=False))
            layers.append(nn.BatchNorm1d(features))
            layers.append(nn.ReLU(inplace=True))
        layers.append(nn.Conv1d(in_channels=features, out_channels=channels,
                                kernel_size=kernel_size, padding=padding, bias=False))
        self.dncnn = nn.Sequential(*layers)


    def forward(self, x):
        out = self.dncnn(x)
        return x-out

if __name__ == '__main__':
    net = DnCNN(1)
    summary(net, input_size=(1,16384), batch_size=32, device="cpu")
    # print(net)
赞赏

微信赞赏 支付宝赞赏

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注