最近用C++和python联合编程的时候,python脚本运行tensorflow的速度太慢了,所以自己用c++去写LSTM神经网络的逻辑。
LSTM中需要用到矩阵的对应元素相乘,也就是点乘,搜了下没有博客写,就自己去找Eigen的文档。
发现Matrix类的默认乘法 * 是叉乘,而点乘dot只能用于向量
Remember that cross product is only for vectors of size 3. Dot product
is for vectors of any sizes. When using complex numbers, Eigen’s dot
product is conjugate-linear in the first variable and linear in the
second variable.
#include <Eigen/Dense>
#include <iostream>
using