繁体   English   中英

张量流中 tf.transpose 的时间复杂度是多少?

[英]What is the time complexity for tf.transpose in tensorflow?

例如,假设我们有一个输入形状为 (10,32,32,3) 的张量a ,这意味着 10 张 32*32 的 NHWC 格式的 RGB 图片

我想使用tf.transpose(b, perm=[0, 3, 1, 2])将其转换为 NCHW 格式

这个操作的时间复杂度是多少?

- - - - -向前 - - - - -

我发现numpy转置函数的时间复杂度是O(1),根据下面的链接

https://www.thetopsites.net/article/58279082.shtml

这在tf中是一样的吗?

二维矩阵的矩阵转置是O(dim1*dim2)

对于 3D 矩阵,它将是O(dim1*dim2*dim3)等等。

根据消息来源

@compatibility(numpy)
  In `numpy` transposes are memory-efficient constant time operations as they
  simply return a new view of the same data with adjusted `strides`.
  TensorFlow does not support strides, so `transpose` returns a new tensor with
  the items permuted.
@end_compatibility

这意味着复杂性取决于张量的维度。 假设你有kn尺寸的维度,这意味着O(n^k)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM