#!/usr/bin/env python
# -*- coding: utf-8 -*-

import tensorflow as tf 

x = tf.constant(2)
y = tf.constant(20)
z = tf.Variable([[6,1,2],[3,4,5],[0,0,0],[8,2,4]])
mask=z[:,0]>0
res = tf.boolean_mask(z,mask)

init_assign = tf.global_variables_initializer()
with tf.Session() as sess:
    sess.run(init_assign)

print sess.run(res)

运行结果:

[[6 1 2]
 [3 4 5]
 [8 2 4]]

TF随笔-10的更多相关文章

  1. TF随笔-8

    #!/usr/bin/env python2 # -*- coding: utf-8 -*- """ Created on Mon Jul 10 09:35:04 201 ...

  2. TF随笔-4

    >>> import tensorflow as tf>>> a=tf.constant([[1,2],[3,4]])>>> b=tf.const ...

  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. TF随笔-11

    #!/usr/bin/env python2 # -*- coding: utf-8 -*- import tensorflow as tf my_var=tf.Variable(0.) step=t ...

  5. TF随笔-7

    求平均值的函数 reduce_mean axis为1表示求行 axis为0表示求列 >>> xxx=tf.constant([[1., 10.],[3.,30.]])>> ...

  6. TF随笔-13

    import tensorflow as tf a=tf.constant(5) b=tf.constant(3) res1=tf.divide(a,b) res2=tf.div(a,b) with ...

  7. TF随笔-9

    计算累加 #!/usr/bin/env python2 # -*- coding: utf-8 -*-"""Created on Mon Jul 24 08:25:41 ...

  8. tf随笔-6

    import tensorflow as tfx=tf.constant([-0.2,0.5,43.98,-23.1,26.58])y=tf.clip_by_value(x,1e-10,1.0)ses ...

  9. tf随笔-5

    # -*- coding: utf-8 -*-import tensorflow as tfw1=tf.Variable(tf.random_normal([2,6],stddev=1))w2=tf. ...

随机推荐

  1. 屏幕变黑白-winhotkey

    下载了个windows hot key 的工具想看快捷键冲突 结果安装好之后屏幕变黑白了,变成辅助模式了.而且鼠标移动到哪都加蓝色框框  如果这个时候你带上耳机就能听到在朗读,这应该也是一种辅助模式 ...

  2. 20145307第9周JAVA学习报告

    20145307陈俊达 <Java程序设计>第9周学习总结 教材学习内容总结 JDBC(Java DataBase Connectivity)即java数据库连接,是一种用于执行SQL语句 ...

  3. python-运算、分支、深浅拷贝

      算术表达式: + - * / 除法Python3中是默认向浮点数靠拢 //取整运算   结果的最小整数靠拢  向下 5 // 2 = 2(向下取整) %取余运算 5 % 2 = 1 **幂值运算 ...

  4. Spring Boot 上传图片文件

    步骤一:基于前面springboot入门小demo 基于的springboot入门小demo,已包含了前面文章的知识点(比如:热部署.全局异常处理器). 步骤二:创建uploadPage.jsp上传页 ...

  5. [Network Architecture]Mask R-CNN论文解析(转)

    前言 最近有一个idea需要去验证,比较忙,看完Mask R-CNN论文了,最近会去研究Mask R-CNN的代码,论文解析转载网上的两篇博客 技术挖掘者 remanented 文章1 论文题目:Ma ...

  6. Maximal Rectangle, 求矩阵中最大矩形,参考上一题

    问题描述: Given a 2D binary matrix filled with 0's and 1's, find the largest rectangle containing only 1 ...

  7. [BZOJ3244][NOI2013]树的计数

    这题大家为什么都写O(NlogN)的算法呢?…… 让本蒟蒻来写一个O(N)的吧…… 首先还是对BFS序和DFS序重编号,记标好的DFS序为d[1..n].令pos[x]为x在d[]中出现的位置,即po ...

  8. vue-cli router的使用

    用了很久这个vue-cli到现在连入门都算不了,为了防止忘记还是很有必要记一下随笔的. 关于vue-cli中的router的使用,, 我将所有页面都存放在components文件夹下, 灰后通过rou ...

  9. JavaScript权威指南--语句

    知识要点 在javascript中,表达式是短语,那么语句(statement)就是整句或命令.表达式计算出一个值,但语句用来执行以使某件事发生. 1.表达式语句 具有副作用的表达式是JavaScri ...

  10. Runtime.getRuntime.exec();

    杀死Chrome浏览器进程 private static void closeAllChrome() throws IOException{ Runtime.getRuntime().exec(&qu ...