转载自:https://www.cnblogs.com/mdumpling/p/8053376.html

  • 原型

tf.squeeze(input, squeeze_dims=None, name=None)

从tensor中删除所有大小是1的维度

给定张量输入,此操作返回相同类型的张量,并删除所有尺寸为1的尺寸。 如果不想删除所有大小是1的维度,可以通过squeeze_dims指定。

  • 参数解释
  1. input: A Tensor. The input to squeeze.
  2. squeeze_dims: An optional list of ints. Defaults to []. If specified, only squeezes the dimensions listed. The dimension index starts at 0. It is an error to squeeze a dimension that is not 1.
  3. name: A name for the operation (optional).
  • 示例
# 't' is a tensor of shape [1, 2, 1, 3, 1, 1]
shape(squeeze(t)) ==> [2, 3]
Or, to remove specific size 1 dimensions: # 't' is a tensor of shape [1, 2, 1, 3, 1, 1]
shape(squeeze(t, [2, 4])) ==> [1, 2, 3, 1]

tf.squeeze()的更多相关文章

  1. tensorflow 笔记14:tf.expand_dims和tf.squeeze函数

    tf.expand_dims和tf.squeeze函数 一.tf.expand_dims() Function tf.expand_dims(input, axis=None, name=None, ...

  2. 深度学习原理与框架-递归神经网络-RNN_exmaple(代码) 1.rnn.BasicLSTMCell(构造基本网络) 2.tf.nn.dynamic_rnn(执行rnn网络) 3.tf.expand_dim(增加输入数据的维度) 4.tf.tile(在某个维度上按照倍数进行平铺迭代) 5.tf.squeeze(去除维度上为1的维度)

    1. rnn.BasicLSTMCell(num_hidden) #  构造单层的lstm网络结构 参数说明:num_hidden表示隐藏层的个数 2.tf.nn.dynamic_rnn(cell, ...

  3. tensorflow 基本函数(1.tf.split, 2.tf.concat,3.tf.squeeze, 4.tf.less_equal, 5.tf.where, 6.tf.gather, 7.tf.cast, 8.tf.expand_dims, 9.tf.argmax, 10.tf.reshape, 11.tf.stack, 12tf.less, 13.tf.boolean_mask

    1.  tf.split(3, group, input)  # 拆分函数    3 表示的是在第三个维度上, group表示拆分的次数, input 表示输入的值 import tensorflow ...

  4. tensorflow之tf.squeeze()

    tf.squeeze()函数的作用是从tensor中删除所有大小(szie)是1的维度. 给定丈量输入, 此操作返回的是相同类型的张量, 并删除所有尺寸为1的维度.如果不想删除所有尺寸为1的维度, 可 ...

  5. tf.expand_dims和tf.squeeze函数

    from http://blog.csdn.net/qq_31780525/article/details/72280284 tf.expand_dims() Function tf.expand_d ...

  6. 深度学习实践-物体检测-faster-RCNN(原理和部分代码说明) 1.tf.image.resize_and_crop(根据比例取出特征层,进行维度变化) 2.tf.slice(数据切片) 3.x.argsort()(对数据进行排列,返回索引值) 4.np.empty(生成空矩阵) 5.np.meshgrid(生成二维数据) 6.np.where(符合条件的索引) 7.tf.gather取值

    1. tf.image.resize_and_crop(net, bbox, 256, [14, 14], name)  # 根据bbox的y1,x1,y2,x2获得net中的位置,将其转换为14*1 ...

  7. TF常用知识

    命名空间及变量共享 # coding=utf-8 import tensorflow as tf import numpy as np import matplotlib.pyplot as plt; ...

  8. 解释张量及TF的一些API

    张量的定义 张量(Tensor)理论是数学的一个分支学科,在力学中有重要应用.张量这一术语起源于力学,它最初是用来表示弹性介质中各点应力状态的,后来张量理论发展成为力学和物理学的一个有力的数学工具.张 ...

  9. tensorflow2.0 squeeze出错

    用tf.keras写了自定义层,但在调用自定义层的时候总是报错,找了好久才发现问题所在,所以记下此问题. 问题代码 u=tf.squeeze(tf.expand_dims(tf.expand_dims ...

随机推荐

  1. less知识点总结(二)

    变量:以@开头,由于变量只能定义一次,其本质就是“常量”. @nice-blue: #5B83AD; @light-blue: @nice-blue + #; #header { color: @li ...

  2. li设置多选和取消选择的样式、输入数据类型判断

    li设置多选和取消选择的样式: $('li').click(function(){ if($(this).hasClass('active')) {$(this).removeClass('activ ...

  3. Nginx教程(四) Location配置与ReWrite语法 (转)

    Nginx教程(四) Location配置与ReWrite语法 1 Location语法规则 1.1 Location规则 语法规则: location [=|~|~*|^~] /uri/ {… } ...

  4. SFINAE and enable_if

    There's an interesting issue one has to consider when mixing function overloading with templates in ...

  5. 【调试】Visual Studio 调试小技巧(2)-从查看窗口得到更多信息(转载)

    在使用Visual Studio开发调试程序时,我们经常需要打开查看窗口(Watch)来分析变量.有时在查看窗口显示的内容不是很直观.为了能从查看窗口的变量中得到更多的信息,我们需要一些小的技巧.下面 ...

  6. 冒泡排序&&选择排序 以及时间效率对比

    package com.test4; import java.util.*; //Calendar 显示时间 /** * @author qingfeng * 功能:冒泡排序 */ public cl ...

  7. laravel 中使用tinker 验证驱动加载是否成功

    在验证laravel 中   InvalidArgumentException Driver [WeiBo] not supported. public function weibo() { retu ...

  8. vs code python保存时pylint提示"Unable to import 'flask'"

    在配置vscode python开发环境时,编写如下代码并保存时,会提示Unable to import 'flask' from flask import Flask app = Flask(__n ...

  9. vb.net机房收费系统——存储过程

    版权声明:本文为博主原创文章.未经博主同意不得转载. https://blog.csdn.net/xdd19910505/article/details/35574125 一.使用背景         ...

  10. 一条数据的漫游 -- X-Engine SIGMOD Paper Introduction

    大多数人追寻永恒的家园(归宿),少数人追寻永恒的航向. ----瓦尔特.本雅明 背景 X-Engine是阿里数据库产品事业部自研的OLTP数据库存储引擎,作为自研数据库POLARDB X的存储引擎,已 ...