eigen

TensorFlow C++接口编译和使用

风流意气都作罢 提交于 2021-01-13 20:01:55
部分内容from: Tensorflow C++ 从训练到部署(1):环境搭建 在之前的编译中,已经编译好了tensorflow_pkg相关的wheel。现在有一个需求,需要按照C++的代码进行模型加载和训练。查询资料后发现,需要重新编译一套TensorFlow支持的C++接口,主要是编译出来libtensorflow_cc.so和libtensorflow_framework.so这两个文件。 bazel build -c opt --copt=-mavx --copt=-msse4.2 --config=monolithic // tensorflow:libtensorflow_cc.so bazel build -c opt --copt=-mavx --copt=-msse4.2 --config=monolithic // tensorflow:libtensorflow_framework.so 像这种严格与机器相关的选项,虽然可以加快执行速度,但是在使用之前一定要查明自己的目标机器是否适合。 中间可能会遇到之前的一些问题,功查找https://www.cnblogs.com/jourluohua/p/9180709.html 编译完成后,安装第三方库 source tensorflow/contrib/makefile/build_all_linux. sh 若出现

Alignment issues with std::vector

倖福魔咒の 提交于 2021-01-05 03:34:16
问题 I finally ran into the annoying issue described here: https://eigen.tuxfamily.org/dox/group__TopicStlContainers.html I have a structure containing several Eigen fixed-size matrices, and i want to store several instances of my structure in a std::vector. So obviously 'These issues arise only with fixed-size vectorizable Eigen types and structures having such Eigen objects as member.' applies. However, it is only described how to solve the issue with vectors directly collecting Eigen Objects,

Alignment issues with std::vector

对着背影说爱祢 提交于 2021-01-05 03:30:55
问题 I finally ran into the annoying issue described here: https://eigen.tuxfamily.org/dox/group__TopicStlContainers.html I have a structure containing several Eigen fixed-size matrices, and i want to store several instances of my structure in a std::vector. So obviously 'These issues arise only with fixed-size vectorizable Eigen types and structures having such Eigen objects as member.' applies. However, it is only described how to solve the issue with vectors directly collecting Eigen Objects,

Alignment issues with std::vector

谁说胖子不能爱 提交于 2021-01-05 03:29:19
问题 I finally ran into the annoying issue described here: https://eigen.tuxfamily.org/dox/group__TopicStlContainers.html I have a structure containing several Eigen fixed-size matrices, and i want to store several instances of my structure in a std::vector. So obviously 'These issues arise only with fixed-size vectorizable Eigen types and structures having such Eigen objects as member.' applies. However, it is only described how to solve the issue with vectors directly collecting Eigen Objects,

Alignment issues with std::vector

♀尐吖头ヾ 提交于 2021-01-05 03:29:07
问题 I finally ran into the annoying issue described here: https://eigen.tuxfamily.org/dox/group__TopicStlContainers.html I have a structure containing several Eigen fixed-size matrices, and i want to store several instances of my structure in a std::vector. So obviously 'These issues arise only with fixed-size vectorizable Eigen types and structures having such Eigen objects as member.' applies. However, it is only described how to solve the issue with vectors directly collecting Eigen Objects,

Cpp+Eigen3计算能带程序

被刻印的时光 ゝ 提交于 2021-01-02 12:07:36
这是C++加Eigen3实现的计算能带程序,在不优化的情况下,速度没有matlab快,甚至没有python+numpy快,但是后面会有比较多的for循环,以及通过优化后,速度会大大提升。另外需要搭配一个Python的画图程序。 测试需要加上编译器-O3优化: g++ -std=c++11 -O3 .\Hatree-Fork.cpp -o main #include <iostream> #include <cmath> #include <complex> #include <vector> #include <fstream> #include <iomanip> #include "../Eigen3/Eigen/Dense" #define EIGEN_USE_MKL_ALL #define EIGEN_VECTORIZE_SSE4_2 const double PI = acos(-1); const double t = -1; // 最近邻hopping const int N = 64; // y方向宽度 // linspace函数 std::vector<double> linspace(const double min, const double max, const int n){ std::vector<double> result; int iterator

Workaround for resizing Eigen::Ref

痴心易碎 提交于 2020-12-13 11:07:27
问题 I want to use Eigen::Ref to have non-template functions using Eigen::Matrix arguments. My problem is that in these functions, I may have to resize the matrices referenced by the Eigen::Ref. I understand that for generality an Eigen::Ref should not be resized because it can map to an expression or a matrix block, but In my case, I am sure that what is behind my Eigen::Ref is an Eigen::Matrix. To illustrate this: #include "Eigen/Dense" void add(Eigen::Ref<Eigen::MatrixXd> M, const Eigen::Ref

Workaround for resizing Eigen::Ref

余生颓废 提交于 2020-12-13 11:06:38
问题 I want to use Eigen::Ref to have non-template functions using Eigen::Matrix arguments. My problem is that in these functions, I may have to resize the matrices referenced by the Eigen::Ref. I understand that for generality an Eigen::Ref should not be resized because it can map to an expression or a matrix block, but In my case, I am sure that what is behind my Eigen::Ref is an Eigen::Matrix. To illustrate this: #include "Eigen/Dense" void add(Eigen::Ref<Eigen::MatrixXd> M, const Eigen::Ref

Workaround for resizing Eigen::Ref

依然范特西╮ 提交于 2020-12-13 11:06:26
问题 I want to use Eigen::Ref to have non-template functions using Eigen::Matrix arguments. My problem is that in these functions, I may have to resize the matrices referenced by the Eigen::Ref. I understand that for generality an Eigen::Ref should not be resized because it can map to an expression or a matrix block, but In my case, I am sure that what is behind my Eigen::Ref is an Eigen::Matrix. To illustrate this: #include "Eigen/Dense" void add(Eigen::Ref<Eigen::MatrixXd> M, const Eigen::Ref

哈工大硕士生实现11种数据降维算法,代码已开源!

▼魔方 西西 提交于 2020-12-03 14:37:37
点击“ 开发者技术前线 ”,选择“星标🔝” 在看|星标|留言, 真爱 来自:相约机器人 编辑:huber 大家好,我是huber! 网上关于各种降维算法的资料参差不齐,同时大部分不提供源代码。这里有个 GitHub 项目整理了使用 Python 实现了 11 种经典的数据抽取(数据降维)算法,包括:PCA、LDA、MDS、LLE、TSNE 等,并附有相关资料、展示效果;非常适合机器学习初学者和刚刚入坑数据挖掘的小伙伴。 01 为什么要进行数据降维? 所谓降维,即用一组个数为 d 的向量 Zi 来代表个数为 D 的向量 Xi 所包含的有用信息,其中 d<D;通俗来讲,即将高维度下降至低维度;将高维数据下降为低维数据。 通常,我们会发现大部分数据集的维度都会高达成百乃至上千,而经典的 MNIST,其维度都是 64。 MNIST 手写数字数据集 但在实际应用中,我们所用到的有用信息却并不需要那么高的维度,而且每增加一维所需的样本个数呈指数级增长,这可能会直接带来极大的「维数灾难」;而数据降维就可以实现: 使得数据集更易使用 确保变量之间彼此独立 降低算法计算运算成本 去除噪音 一旦我们能够正确处理这些信息,正确有效地进行降维,这将大大有助于减少计算量,进而提高机器运作效率。而数据降维,也常应用于文本处理、人脸识别、图片识别、自然语言处理等领域。 02 数据降维原理