cntk - CNTK - reshape an axis to matrix
问题描述
Given a Tensor whose shape is known only at the compute time, how to convert a Tensor of shape, for e.g., (n1, n2, m*n)
to (n1, n2, m, n)
assuming there is a prior condition that, the last dimension is strictly a multiple of n.
解决方案
因为,我们拥有的唯一信息是最后一个维度是 n 的倍数,所以下面的代码行就可以解决问题。这里,x 是一个张量变量,其形状是在网络编译时计算的。
x = C.reshape(x, x.shape[:-1] + (-1, n))
推荐阅读
- assembly - Why do kill dependency instructions consume reservation station slots?
- python - Azure Blob 绑定与 Azure 函数 (Python)
- php - Postgres & PHP- 将 UTC 时间戳转换为本地时间
- java - 如何在可执行的 java shebang 文件中指定类路径
- mobile - 推荐系统模型 (DNN) 可以在 TensorFlow Lite 中转换以进行移动设备推理吗?
- sql - 红移将十进制转换为十进制
- c# - C# string.split on readline 不产生预期的数组长度
- r - {tidyr} 扩展函数删除行的问题
- python - 读取文件最后一行的函数?
- arrays - 使用赛普拉斯存储元素数组