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.

padding.py 531 B

12345678910111213141516171819202122
  1. from typing import Tuple
  2. from ..functional import nn
  3. from .module import Module
  4. class Pad(Module):
  5. def __init__(
  6. self,
  7. pad_witdth: Tuple[Tuple[int, int], ...],
  8. mode: str = "CONSTANT",
  9. constant_val: float = 0.0,
  10. ):
  11. super().__init__()
  12. self.pad_width = pad_witdth
  13. self.mode = mode
  14. self.pad_val = constant_val
  15. def forward(self, src):
  16. return nn.pad(
  17. src, pad_witdth=self.pad_width, mode=self.mode, constant_value=self.pad_val
  18. )

MegEngine 安装包中集成了使用 GPU 运行代码所需的 CUDA 环境,不用区分 CPU 和 GPU 版。 如果想要运行 GPU 程序,请确保机器本身配有 GPU 硬件设备并安装好驱动。 如果你想体验在云端 GPU 算力平台进行深度学习开发的感觉,欢迎访问 MegStudio 平台