我正在尝试编译 pytorch 转换器以在 C++ 中运行它:
from torch.nn import TransformerEncoder, TransformerEncoderLayer
encoder_layers = TransformerEncoderLayer(1000, 8, 512, 0.1)
transf = TransformerEncoder(encoder_layers, 6)
sm = torch.jit.script(transf)
但我收到一个错误:
RuntimeError: Expected a default value of type Tensor on parameter
"src_mask": File "C:\Program Files (x86)\Microsoft Visual
Studio\Shared\Python36_64\lib\site-packages\torch\nn\modules\transformer.py",
line 271
def forward(self, src, src_mask=None, src_key_padding_mask=None):
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~... <--- HERE
r"""Pass the input through the encoder layer.
pytorch 变压器模块看起来有问题。
有没有办法在 C++ 中运行 pytorch 转换器?