tf.where()函数的解析
tf.where()的使用,该函数会返回满足条件的索引。经验证,发现返回均是二维矩阵,可以说明该函数用二维
矩阵给出满足条件的位置索引。(若有错误,欢迎指正。) 代码如下:
import tensorflow as tf
sess=tf.Session()
import numpy as np
print('验证一维矩阵,tf.where()返回的索引:')
target_class_ids=np.array([4,5,3,6,2])
positive_roi_ix = tf.where(target_class_ids > 0)
positive_roi_ix=sess.run(positive_roi_ix)
print(positive_roi_ix)
print('验证三维矩阵,tf.where()返回的索引:')
target_class_ids=np.array([[4,5,3,6,2],[4,5,3,6,-2]])
positive_roi_ix = tf.where(target_class_ids > 0)
positive_roi_ix=sess.run(positive_roi_ix)
print(positive_roi_ix)
print('验证三维矩阵,tf.where()返回的索引:')
target_class_ids=np.array([[[4,5,3,6,2],[4,5,3,6,-2]],[[4,5,3,6,2],[4,5,3,6,-2]]])
positive_roi_ix = tf.where(target_class_ids > 0)
positive_roi_ix=sess.run(positive_roi_ix)
print(positive_roi_ix) 结果如下:
验证一维矩阵,tf.where()返回的索引:
[[0]
[1]
[2]
[3]
[4]]
验证三维矩阵,tf.where()返回的索引:
[[0 0]
[0 1]
[0 2]
[0 3]
[0 4]
[1 0]
[1 1]
[1 2]
[1 3]]
验证三维矩阵,tf.where()返回的索引:
[[0 0 0]
[0 0 1]
[0 0 2]
[0 0 3]
[0 0 4]
[0 1 0]
[0 1 1]
[0 1 2]
[0 1 3]
[1 0 0]
[1 0 1]
[1 0 2]
[1 0 3]
[1 0 4]
[1 1 0]
[1 1 1]
[1 1 2]
[1 1 3]]
tf.where()函数的解析的更多相关文章
- tf.transpose函数解析
tf.transpose函数解析 觉得有用的话,欢迎一起讨论相互学习~Follow Me tf.transpose(a, perm = None, name = 'transpose') 解释 将a进 ...
- tf.slice函数解析
tf.slice函数解析 觉得有用的话,欢迎一起讨论相互学习~Follow Me tf.slice(input_, begin, size, name = None) 解释 : 这个函数的作用是从输入 ...
- 字串符相关 split() 字串符分隔 substring() 提取字符串 substr()提取指定数目的字符 parseInt() 函数可解析一个字符串,并返回一个整数。
split() 方法将字符串分割为字符串数组,并返回此数组. stringObject.split(separator,limit) 我们将按照不同的方式来分割字符串: 使用指定符号分割字符串,代码如 ...
- Generator函数语法解析
转载请注明出处: Generator函数语法解析 Generator函数是ES6提供的一种异步编程解决方案,语法与传统函数完全不同.以下会介绍一下Generator函数. 写下这篇文章的目的其实很简单 ...
- tensorflow 笔记14:tf.expand_dims和tf.squeeze函数
tf.expand_dims和tf.squeeze函数 一.tf.expand_dims() Function tf.expand_dims(input, axis=None, name=None, ...
- TensorFlow随机值:tf.random_normal函数
tf.random_normal 函数 random_normal( shape, mean=0.0, stddev=1.0, dtype=tf.float32, seed=None, name=No ...
- tf.transpose函数的用法讲解
tf.transpose函数中文意思是转置,对于低维度的转置问题,很简单,不想讨论,直接转置就好(大家看下面文档,一看就懂). tf.transpose(a, perm=None, name='tra ...
- tensorflow中 tf.reduce_mean函数
tf.reduce_mean 函数用于计算张量tensor沿着指定的数轴(tensor的某一维度)上的的平均值,主要用作降维或者计算tensor(图像)的平均值. reduce_mean(input_ ...
- tf.random_normal()函数
tf.random_normal()函数用于从服从指定正太分布的数值中取出指定个数的值. tf.random_normal(shape, mean=0.0, stddev=1.0, dtype=tf. ...
随机推荐
- Vue--过滤器、指令、插件
常用下载js的网址: https://www.bootcdn.cn/ https://www.jsdelivr.com/ 一.过滤器 vue 允许自定义过滤器,用于格式化一些常见文本(如日期等). 1 ...
- echarts水球图编写
// 前提条件 需要引入这个插件<script src="./echarts-liquidfill.min.js"></script> // 代码 let ...
- Linux(ubuntu) 三行代码搞定安装谷歌浏览器
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb 然后再输入: sudo dpkg -i g ...
- Java 静态工厂模式的使用
多相关文章请参考:http://www.enjoytoday.cn/categorys/java 静态工厂模式给人的第一印象就是:static+abstract.这两个词汇已经说明了一切,一个是周期长 ...
- 学习springboot第一天~
1. springboot是对spring的缺点进行改善和优化,它的约定大于配置,开箱即用,没有代码生成,也不需要xml文件配置,可以修改属性值来满足需求 2. springboot的入门程序 在id ...
- 最新内核3.4)Linux 设备树加载I2C client adapter 的流程(内核3.4 高通)【转】
转自:https://blog.csdn.net/lsn946803746/article/details/52515225 版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转 ...
- eclipse的“sun.misc.BASE64Encoder”问题解决
新建一个AndroidHello工程,编译运行,出现问题如下: 编辑/Applications/Eclipse.app/Contents/Eclipse/eclipse.ini文件,加入 -vm /L ...
- Shell命令-网络操作之基础之scp、wget
文件及内容处理 - scp.wget 1. scp:用于不同主机之间复制文件 scp命令的功能说明 scp 命令用于 Linux 之间复制文件和目录.scp 是 secure copy 的缩写, sc ...
- 3. Go语言—函数和常量
一.函数声明和注释 1. 声明 func 函数名 (参数列表)(返回值列表){} func add{ pass } func add(a int, b int){ } func add(a int ...
- C++中的异常处理(中)
为什么要在catch中重新抛出异常? #include <iostream> #include <string> using namespace std; void Demo( ...