tf.transpose 直观感受

简介: import tensorflow as tf import numpy as np a = np.array([[[1, 2, 3],[1, 2, 3],[1, 2, 3]], [[1, 2, 3],[1, 2, 3],[1, 2, 3]], [[1, 2, 3],[1, 2, 3],[1, 2, 3]]]) before_trans = np.



tensorflow cifar10的cifar10_input.py中read_cifar10()最后有一个转置语句

result.uint8image = tf.transpose(depth_major, [1, 2, 0])


用以下语句直观感受一下


import as 

import numpy as np


1231231231231231231231231231'depth'2'height'3'width'dtypeshape333perm120with as feed_dictprintprintfor in rangelen0for in rangelen1for in rangelen2for in rangelen0for in rangelen1for in rangelen2printprint'before_trans:\n'print

print('after_trans:\n',np.array(after_trans))





# 结果

before_trans: [[['depth' 'height' 'width'] ['depth' 'height' 'width'] ['depth' 'height' 'width']] [['depth' 'height' 'width'] ['depth' 'height' 'width'] ['depth' 'height' 'width']] [['depth' 'height' 'width'] ['depth' 'height' 'width'] ['depth' 'height' 'width']]] after_trans: [[['depth' 'depth' 'depth'] ['height' 'height' 'height'] ['width' 'width' 'width']] [['depth' 'depth' 'depth'] ['height' 'height' 'height'] ['width' 'width' 'width']] [['depth' 'depth' 'depth'] ['height' 'height' 'height'] ['width' 'width' 'width']]]


目录
相关文章
|
19天前
|
机器学习/深度学习 PyTorch 算法框架/工具
PyTorch基础之激活函数模块中Sigmoid、Tanh、ReLU、LeakyReLU函数讲解(附源码)
PyTorch基础之激活函数模块中Sigmoid、Tanh、ReLU、LeakyReLU函数讲解(附源码)
92 0
|
19天前
|
存储 机器学习/深度学习 PyTorch
PyTorch核心--tensor 张量 !!
PyTorch核心--tensor 张量 !!
34 1
|
19天前
|
机器学习/深度学习 数据可视化 算法
【学习打卡04】可解释机器学习笔记之Grad-CAM
【学习打卡04】可解释机器学习笔记之Grad-CAM
|
12月前
对两个flatten函数的探究
对两个flatten函数的探究
55 0
|
PyTorch 算法框架/工具
pytorch如何将多个tensor一维度张量,合并成一个张量
在 PyTorch 中,可以使用 torch.cat() 函数将多个张量沿着指定维度进行合并。下面是一个例子:
1304 0
|
机器学习/深度学习 计算机视觉
Batch Normalization, 批标准化,神经网络shortcut 是什么,无脑用ReLU(CV领域). 无脑用3x3.
和普通的数据标准化类似, 是将分散的数据统一的一种做法, 也是优化神经网络的一种方法. 在之前 Normalization 的简介视频中我们一提到, 具有统一规格的数据, 能让机器学习更容易学习到数据之中的规律.
358 0
|
机器学习/深度学习 PyTorch 算法框架/工具
Tensor:Pytorch神经网络界的Numpy(二)
Tensor:Pytorch神经网络界的Numpy(二)
189 0
Tensor:Pytorch神经网络界的Numpy(二)
|
机器学习/深度学习 PyTorch 算法框架/工具
Tensor:Pytorch神经网络界的Numpy(一)
Tensor:Pytorch神经网络界的Numpy(一)
139 0
Tensor:Pytorch神经网络界的Numpy(一)
|
人工智能 自然语言处理 Python
TF-IDF:概念与python实现
TF-IDF:概念与python实现
TF-IDF:概念与python实现
|
机器学习/深度学习 算法 Python
TF之LSTM:利用基于顺序的LSTM回归算法对DIY数据集sin曲线(蓝虚)预测cos(红实)(matplotlib动态演示)—daiding
TF之LSTM:利用基于顺序的LSTM回归算法对DIY数据集sin曲线(蓝虚)预测cos(红实)(matplotlib动态演示)—daiding
TF之LSTM:利用基于顺序的LSTM回归算法对DIY数据集sin曲线(蓝虚)预测cos(红实)(matplotlib动态演示)—daiding