在torch模型转onnx模型,我会生成一个随机序列,通过模型预测看输出的维度是否一致吗但是遇到这个报错
我是这样生成的
dummy_input = torch.randn(1,1,1200)
dummy_output = model_pytorch(dummy_input)
print(dummy_output.shape)
RuntimeError: expected scalar type Long but found Float
解决方式:
修改第一句,指定dtype
dummy_input = torch.randn(1,1,1200, dtype=torch.float)
dummy_output = model_pytorch(dummy_input)
print(dummy_output.shape)