c++ - Dlib 元素特定操作

标签 c++ machine-learning dlib

使用 dlib 库如何进行元素特定操作?例如

A = [1 2 3; 4 5 6]

我可以让它对矩阵的元素进行平方,而不是 A*A,这样答案就是

ans = [1 4 9; 16 25 36]

在 matlab 中你可以简单地去 A.^2

谢谢

最佳答案

您可以使用库“matrix.h”中的pointwise_multiply()。 例如

matrix<double> A(3,2);
A = 1,    2,
    3,    4,
    5,    6;

matrix<double> B(3,2);
B = 1,    2,
    3,    4,
    5,    6;

matrix<double> answer = pointwise_multiply(A,B);

或者另一种方式

matrix<double> answer = squared(A);

关于c++ - Dlib 元素特定操作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28577371/

相关文章:

python-2.7 - 无法从朴素贝叶斯分类器生成 ROC-AUC 曲线

machine-learning - XGBoostplot_importance无法显示特征名称

python - dlib形状预测器模型的参数

c++ - Linked List no match for operator* 编译器错误

c++ - Boost::进程管链

c++ - wxWidgets 3.0 - 新特性和功能、添加和替换已弃用的功能

c++ - 将 int 元组转换为 int 并返回

machine-learning - scikit-learn TfidfVectorizer 含义?

python - Dlib "Error deserializing object of type short"

python - Python面部识别脚本意外停止