You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

DepthwiseSeparableConvolution.py 1.3 kB

123456789101112131415161718192021222324252627282930313233343536373839
  1. """ Depthwise and Separable Convolution """
  2. import mindspore as ms
  3. from mindspore import nn
  4. class DepthwiseSeparableConvolution(nn.Cell):
  5. """ DepthwiseSeparableConvolution """
  6. def __init__(self,
  7. in_channels,
  8. out_channels,
  9. kernel_size=3,
  10. stride=1,
  11. padding=1):
  12. super().__init__()
  13. self.depthwise_conv = nn.Conv2d(in_channels=in_channels,
  14. out_channels=in_channels,
  15. kernel_size=kernel_size,
  16. stride=stride,
  17. pad_mode='pad',
  18. padding=padding)
  19. self.pointwise_conv = nn.Conv2d(in_channels=in_channels,
  20. out_channels=out_channels,
  21. kernel_size=1,
  22. stride=1,
  23. group=1)
  24. def construct(self, x):
  25. x = self.depthwise_conv(x)
  26. out = self.pointwise_conv(x)
  27. return out
  28. if __name__ == '__main__':
  29. in_tensor = ms.ops.randn((1, 3, 224, 224), dtype=ms.float32)
  30. conv = DepthwiseSeparableConvolution(3, 64)
  31. output = conv(in_tensor)
  32. print(output.shape)

基于MindSpore的多模态股票价格预测系统研究 Informer,LSTM,RNN