def where_v2(condition, x=None, y=None, name=None):

  1. 参数只有condition;
tf.where([True,False,False,True])
return: <tf.Tensor:shape=(2,1),dtype=int64,
numpy=array([[0],[3]])
tf.where([[True,False],[False,True]])*tf.Tensor:shape=(2,2),dtype=int64,
numpy=array([[0,0],[1,1]])>
tf.where([[[True,False],[False,True],[True,True]]])
tf.Tensor:shape=(4,3),dtype=int64,
numpy=array([[0,0,0],[0,1,1],[0,2,0],[0,2,1]])

Theconditiontensor actssa mask that chooses whether the corresponding

element/row in the output should be taken fromx

(if the elemment inconditionisTrue) ory`(if it is false).

*存在条件的时候如果条件是true,返回x,*否则返回y

 tf.where([True, False, False, True], [1,2,3,4], [100,200,300,400])<tf.Tensor: shape=(4,), dtype=int32, numpy=array([  1, 200, 300,   4],dtype=int32)

两个数组[1, 2, 3, 4] and [100, 200, 300, 400]
对照条件[True, False, False, True],可知条件数组为True下标为[0, 3] 所以选择x中的元素1和元素4,剩下从y矩阵选择;

tf.where([True, False, False, True], 1, 100)<tf.Tensor: shape=(4,), dtype=int32, numpy=array([  1, 100, 100,   1],dtype=int32)>

【tensorflow】tf-tf.where(condition, x, y, name)相关推荐

  1. 【TensorFlow】理解tf.nn.conv2d方法 ( 附代码详解注释 )

    最近在研究学习TensorFlow,在做识别手写数字的demo时,遇到了tf.nn.conv2d这个方法,查阅了官网的API 发现讲得比较简略,还是没理解.google了一下,参考了网上一些朋友写得博 ...

  2. 【TensorFlow】(七)tf.feature_column.crossed_column()函数的作用及用法

    1.作用 对hash映射之后的特征进行交叉. 优势:特征交叉,在有些情况下,特征独自编码与多维特征交叉后的特征特性会有不一样的结果. 使用方式: tf.feature_column.crossed_c ...

  3. 【TensorFlow】(四)tf.feature_column.embedding_column()函数

    1.作用 将sparse/categrical特征转化为dense 向量.one-hot产生的向量,易造成数据的稀疏化,对于推荐系统而言,大维度的稀疏数据对于结果的影响较大,因此我们考虑使用embed ...

  4. 【Tensorflow】tf.nn.atrous_conv2d如何实现空洞卷积?膨胀卷积

    介绍 关于空洞卷积的理论可以查看以下链接,这里我们不详细讲理论: 1.Long J, Shelhamer E, Darrell T, et al. Fully convolutional networ ...

  5. 【TensorFlow】tf.nn.softmax_cross_entropy_with_logits的用法

    [TensorFlow]tf.nn.softmax_cross_entropy_with_logits的用法 from:https://blog.csdn.net/mao_xiao_feng/arti ...

  6. 【TensorFlow】tf.nn.softmax_cross_entropy_with_logits中的“logits”到底是个什么意思?

    tf.nn.softmax_cross_entropy_with_logits中的"logits"到底是个什么意思?_玉来愈宏的随笔-CSDN博客 https://blog.csd ...

  7. 【TensorFlow】tf.nn.softmax_cross_entropy_with_logits 函数:求交叉熵损失

    [TensorFlow]tf.nn.softmax_cross_entropy_with_logits的用法_xf__mao的博客-CSDN博客 https://blog.csdn.net/mao_x ...

  8. 【Tensorflow】tf.nn.depthwise_conv2d如何实现深度卷积?+深度可分离卷积详解

    目录 常规卷积操作 深度可分离卷积 = 逐通道卷积+逐点卷积 1.逐通道卷积 2.逐点卷积 参数对比 介绍 实验 代码清单 一些轻量级的网络,如mobilenet中,会有深度可分离卷积depthwis ...

  9. 【Tensorflow】 tf.equal(tf.argmax(y, 1),tf.argmax(y_, 1))用法

    [Tensorflow] tf.equal(tf.argmax(y, 1),tf.argmax(y_, 1))用法 作用:输出正确的预测结果 利用tf.argmax()按行求出真实值y_.预测值y最大 ...

  10. 【tensorflow】Sequential 模型方法 compile, model.compile

    Sequential 顺序模型 API - Keras 中文文档 https://keras.io/zh/models/sequential/ Sequential 序贯模型 序贯模型是函数式模型的简 ...

最新文章

  1. Java compiler level does not match the version of the installed Java project facet.
  2. 安卓constraintLayout中app:srcCompat设置的图片显示不出来
  3. 一键进入dfu模式软件_dfu模式是什么 dfu模式介绍及进入方法【详解】
  4. 微信语音怎么转发给别人听_微信语音怎么转发出去?这个小技巧超级好用
  5. oracle Constraint(转)
  6. delphi之模糊找图
  7. 多线程编程(三)--创建线程之Thread VS Runnable
  8. ES6 Map和Set的用法笔记
  9. 一个用于伪造IP地址进行爆破的BurpSuite插件:BurpFakeIP
  10. 构建微服务:Spring boot 入门篇
  11. 清华大学计算机学院主页,计算机图形学基础课程主页 | 清华大学计算机系
  12. OpenShift 4 之Knative(1) - 创建Knative无服务器架构环境
  13. 类的静态成员函数带来了什么好处,应该在什么时候使用?
  14. 程序员音乐_预订音乐会的程序员指南
  15. 为什么C语言执行效率高,运行快?
  16. ipv6的linux安装
  17. idea中更换java版本
  18. 关于NB-IOT模块链接阿里物联网平台的学习笔记-记录
  19. 如何使用vps 异地组网_异地组网简要配置指南
  20. K3老单开发-销售订单计算比例(实际价格反推)

热门文章

  1. java file pathname_int compareTo(File pathname)
  2. Python-OpenCV 笔记5 -- 几何变换(Geometric Transformations)
  3. Python学习系列day5-python基础
  4. rust(72)-match匹配
  5. 【NLP】在机器学习中开发情感分析器的5种方法
  6. 【特征工程】不容错过的 5 种特征选择的方法!
  7. 原文翻译:深度学习测试题(L1 W3 测试题)
  8. 小目标检测、图像分类、图像识别等开源数据集汇总
  9. Google又发大招:高效实时实现视频目标检测
  10. 《周四橄榄球之夜》流媒体视频拆解:Twitch VS Amazon Prime