张量征服,我如何选择应收缩的索引
Tensor-contraction, how do i choose the indexes which should be contracted over?
我想用eigen :: tensor模块执行简单的张量合同,但是到目前为止,我不理解您对正确的尺寸进行调整的方式。
这是我当前的代码:
Eigen::Tensor<double, 3> B(3,4,3); B.setRandom();
Eigen::Tensor<double, 3> C(3,4,3); C.setRandom();
// Eigen::array<Eigen::IndexList<int,int,int>,1> idx =
// {Eigen::IndexList<int,int,int>(1,0,0)};
// also does not seem to be the way
Eigen::array<int,3> idx({0,0,1});
Eigen::Tensor<double, 4> D = B.contract(C, idx);
我只想在 b 的最后一个维度和 c 的第一个维度上收缩。但是我不明白系统的工作原理,并且文档仅为您提供了2D量的示例。
//the first element of IDXPair is the choosen index in B and the second the idx for C
Eigen::array<Eigen::IndexPair<int>,1> idx = {Eigen::IndexPair<int>(2,0)};
在这里,第二个索引将乘以第二个张量的零。
indexpair准确地说明了:张量二措施中的第一个索引映射到第二个张量的第二个索引。
idxpair(a,b)=> a(1,2,3,4,x) * b(x,5,6,7,8,9),其中a是最后一个维度的索引cas x和b第二张张量
相关文章:
- 如何使用默认参数等选择模板专业化
- 数组索引的值没有增加
- 如何(从固定列表中)选择一个数字序列,该序列将与目标数字相加
- 芬威克树(BIT).找到具有给定累积频率的最小索引,单位为 O(logN)
- 选择要调用的构造函数
- 选择前缀数量最多的索引
- 从动态索引中选择ConstexPR索引
- 使用查找表选择具有运行时索引的可变参数类型
- 张量征服,我如何选择应收缩的索引
- 正确复制 QTableView 中的选择(模型索引问题)
- 使用值为 std::shared_ptr的映射是具有多索引类列表的良好设计选择
- 从STL矢量的真值中随机选择索引
- 如何在C++中按索引选择字符串中的特定字符
- 选择排序获取错误的数组索引
- Q更改当前索引时不选择
- 使用索引从字符串中选择单个字符
- 选择多列索引查询优化
- 构造由索引从类列表中选择的类,c++
- 如何从另一个仅静态选择满足特定类型规则的索引的元组实例创建元组实例
- CUB使用返回的索引选择它