[英]Is there any contiguous function in tensorflow2.0?
In PyTorch, people usually call tensor.permute(2,0,1,3).contiguous()
.在 PyTorch 中,人们通常调用
tensor.permute(2,0,1,3).contiguous()
。 If I call this function in tensorflow 2.0, is it enough to just call tf.reshape(tensor, perm = [2, 0, 1, 3])
?如果我在 tensorflow 2.0 中调用这个 function,只调用
tf.reshape(tensor, perm = [2, 0, 1, 3])
就足够了吗?
or what is a contiguous function in tensorflow 2.0?或者 tensorflow 2.0 中的连续 function 是什么?
From the official docs of tf.transpose ,来自tf.transpose的官方文档,
In
NumPy
, transposes are memory-efficient constant time operations as they simply return a new view of the same data with adjusted strides .在
NumPy
中,转置是内存高效的常数时间操作,因为它们只是返回具有调整步幅的相同数据的新视图。TensorFlow
does not support strides, so transpose returns a new tensor with the items permuted .TensorFlow
不支持步幅,因此 transpose 返回一个新的张量,其中的项目是 permuted 。
Also, TensorFlow
doesn't seem to support Fortran (Column-Major) ordering.此外,
TensorFlow
似乎不支持 Fortran(列主要)排序。 Hence, I think we automatically get Contiguous (Row-Major) ordering tensor.因此,我认为我们会自动获得 Contiguous (Row-Major) 排序张量。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.