无法推导出 Eigen::Matrix 的模板参数

问题描述

当我尝试使用 MSVC 19.latest 编译以下函数 (forward) 时,我收到以下错误消息。

'Eigen::Matrix<float,ann_output_len<LayerNodeConfig...>::value,1,_Rows,1> forward(const  
 ArtificialNeuralNetwork<InputSize,LayerNodeConfig...> &,const Eigen::Matrix<float,Rows,1> &)':  
 Could not deduce template argument for 'const Eigen::Matrix<float,1> &' from  
 'Eigen::Matrix<float,2,1>'

forward 界面

template<int InputSize,int ... LayerNodeConfig>
auto forward(const ArtificialNeuralNetwork<InputSize,LayerNodeConfig...>& ann,const RL::Arrayf<InputSize>& input)     
  -> typename ANN::output_t<LayerNodeConfig...>

main函数

  RL::Arrayf<2> X;
  auto Y = forward(sampling_policy,X);

现在我不明白的是为什么编译器不能用 2 代替 Rows_Rows

任何见解表示赞赏。 您可以使用此链接 https://godbolt.org/z/7Mj5ee 在 Godbolt.org 中尝试完整代码,如果您愿意,可以尝试自己编译。

注意:我尝试用最新的 GCC 编译器编译相同的代码并编译。

更新 - 2021 年 3 月 6 日: 我通过更改函数 forward 的接口以接受 Eigen::DenseBase<Derived> 而不是 RL::Arrayf<InputSize>解决方法。 任何有兴趣的人都可以在这里阅读更多相关信息,https://eigen.tuxfamily.org/dox/TopicFunctionTakingEigenTypes.html

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)