torch7:如何获取张量的维数?

torch7: How to get the dimensionality of a tensor?

给定任何 torch7 张量,如何找到它的维数?

我想用它来检查一个特定的张量是否是一维的,但我对一般的张量很好奇。

t:dim()

我建议您阅读此处的文档:https://github.com/torch/torch7/blob/master/doc/tensor.md