【问题标题】:Libtorch C++ - no matching member function for call to 'size' for InterpolateFuncOptionsLibtorch C++ - 没有匹配的成员函数来调用 InterpolateFuncOptions 的“大小”
【发布时间】:2020-10-08 08:50:41
【问题描述】:

在 C++ 中使用 Libtorch 1.6.0,我收到以下错误:

error: no matching member function for call to 'size'

我的台词如下:

image = F::interpolate(image, F::InterpolateFuncOptions().size({target_height, target_width}).mode(torch::kNearest));

但在文档中它似乎是正确的......有什么想法吗?

提前致谢

【问题讨论】:

  • PyTorch 版本?你试过F::InterpolateFuncOptions().size(std::vector<int64_t>{target_height, target_width})吗?
  • 1.6.0 确实有效。非常感谢:)
  • 为未来的读者添加了一个带有一点上下文的答案。

标签: c++ pytorch libtorch


【解决方案1】:

你应该像这样用std::vector 包裹它:

image = F::interpolate(image, 
        F::InterpolateFuncOptions()
        .size(std::vector<>{target_height, target_width})
        .mode(torch::kNearest));

原因是size 没有对您尝试使用的std::initializer_list 进行重载调用(请参阅size 文档here)。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-06-26
    • 2020-09-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多