[英]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
這意味着復雜性取決於張量的維度。 假設你有k
個n
尺寸的維度,這意味着O(n^k)
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.