# [work]Swap tensor axes in tensorflow

3人阅读 评论(0)

I have a tensor of shape (30,116,10) and I want to swap the first two dimesions, so that I have a tensor of shape (116,30,10)

I saw that numpy as such a function implemented (np.swapaxes) and I searched for something similar in tensorflow but I found nothing.

Do you have any idea ?

Alexis

tf.transpose provides the same functionality as np.swapaxes, although in a more generalized form. In your case, you can do tf.transpose(orig_tensor, [1, 0, 2]) which would be equivalent to np.swapaxes(orig_np_array, 0, 1).

友情链接
个人资料
等级：
访问量： 118万+
积分： 1万+
排名： 772
博客专栏
 c/c++底层知识库 文章：20篇 阅读：43581 算法模板库 文章：34篇 阅读：34659
最新评论