TensorFlow —— expand_dim()函数
来源:互联网 发布:银龙裁决多少钱淘宝价 编辑:程序博客网 时间:2024/06/05 20:45
该函数用于增加tensor(张量)的维数
官方的例子和说明:
# 't' is a tensor of shape [2]shape(expand_dims(t, 0)) ==> [1, 2]shape(expand_dims(t, 1)) ==> [2, 1]shape(expand_dims(t, -1)) ==> [2, 1]# 't2' is a tensor of shape [2, 3, 5]shape(expand_dims(t2, 0)) ==> [1, 2, 3, 5]shape(expand_dims(t2, 2)) ==> [2, 3, 1, 5]shape(expand_dims(t2, 3)) ==> [2, 3, 5, 1]
Args:
input: A Tensor.
dim: A Tensor. Must be one of the following types: int32, int64. 0-D (scalar). Specifies the dimension index at which to expand the shape of input.
name: A name for the operation (optional).
Returns:
A Tensor. Has the same type as input. Contains the same data as input, but its shape has an additional dimension of size 1 added.
使用时需要注意几个点:
1. 一次只能增加一个维度
2. 数据不变,所以增加的维度的数值都是1。比如官方第一个例子里,t 的shape由[2]变成[1,2]或者[2,1],其实[2]和[1,2]除了维度数之外没有区别,即都是含两个元素,这样就保证数据是不变的。增加的维度的数值必须是1,不可能出现由[2]变成[3,2]或者[2,2]这种情况
3. 注意插入维度的位置,从0开始,-1代表结尾。[(0) a1 (1) a2 (2) a3 (3 or -1)],输入是几,就是特定的位置插入一个 “,1,”
阅读全文
1 0
- TensorFlow —— expand_dim()函数
- tensorflow 的squeeze和expand_dim函数
- TensorFlow用expand_dim()来增加维度
- TensorFlow函数——tf.variable( )
- TensorFlow函数——tf.placeholder()
- Tensorflow函数——tf.set_random_seed(seed)
- Tensorflow函数——tf.variable_scope()
- tensorflow学习——collections.namedtuple函数
- TensorFlow教程——常用函数解析
- tensorflow学习基础篇1——conv2d 函数说明
- TensorFlow 学习(十)—— 工具函数
- TensorFlow 学习(十二)—— 高级函数
- Tensorflow函数说明(3)——queue
- Tensorflow函数说明(4)—— variable_scope/name_scope
- TensorFlow学习笔记(3)——softmax_cross_entropy_with_logits函数详解
- TensorFlow学习笔记之——常用函数(概览)
- TensorFlow深度学习入门——常用函数说明
- tensorflow——tf.one_hot以及tf.sparse_to_dense函数
- 吴恩达deeplearning.ai课程系列笔记05(下)
- react回调给父组件值.txt
- 【笔记】堆及其实现
- 图像复原与重建(1):图像退化与复原过程模型
- Android设计模式之——责任链模式
- TensorFlow —— expand_dim()函数
- 有限自动机
- python中if语句的运用
- portotype和_proto_区别
- hdu 1004 Max Sum 基础dp
- Attention-over-Attention Neural Network for Reading Comprehension----神经网络在阅读理解上的应用
- JSP的内置对象
- 初识Angular
- 程序员已当选最佳国民女婿