#!/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. python3执行js之pyexecjs

    执行js的三种方法:1.阅读js代码,将之转成python2.找到js代码,用python第三方库执行相关代码 python2-pyv8 python3-pyexecjs3.用selenium驱动浏览 ...

  2. MYSQL数据库里面的所有密码批量MD5加密

    如果你的字段够长度的话:UPDATE users SET password = MD5(password);如果长度不够,可以先增加长度后再做,或者多建一列,完成后删除原来的列!(如passwd)UP ...

  3. HBase相关问题

    HBase和Hive的异同之处? 共同点:HBase与Hive都是架构在Hadoop之上,底层存储都是使用HDFS 区别: 1). Hive是建立在Hadoop之上为了减少MapReduce jobs ...

  4. shell编程学习笔记之sed编辑器

    在shell编程中,大多数处理的都是文本文件.对文本文件进行处理除了使用交互式文本编辑器(vi[m],gedit......)也可以使用另外一类:流编辑器. 流编辑器:使用预定义的编辑规则来对文本进行 ...

  5. Xcode Missing file的解决方案

    因为没在工程里面删除文件,导致Xcode报了一大堆警告,都是Missing file的警告,研究了一下,下面是我的解决方案: Missing file出现的原因 原因就是你在文件里面删除了文件,但是在 ...

  6. 2017ACM/ICPC广西邀请赛-重现赛 1001 A Math Problem

    2017-08-31 16:48:00 writer:pprp 这个题比较容易,我用的是快速幂 写了一次就过了 题目如下: A Math Problem Time Limit: 2000/1000 M ...

  7. Python基础笔记系列十二:requests模块的简单应用

    本系列教程供个人学习笔记使用,如果您要浏览可能需要其它编程语言基础(如C语言),why?因为我写得烂啊,只有我自己看得懂!! httpbin httpbin这个网站能测试 HTTP 请求和响应的各种信 ...

  8. poj 2255 Tree Recovery 分治

    Tree Recovery Description Little Valentine liked playing with binary trees very much. Her favorite g ...

  9. java23种设计模式之三: 适配器模式

    一.适配器模式  就是个通过一个中间件转化,可以将不匹配的两件事整合到一起,把不匹配变的匹配. 二.适配器分类 1.类适配器  2.对象适配器 三. 适配器的3种组成 1.类适配器组成 1.2个接口 ...

  10. 初识HTML和CSS

    HTML 1.一套规则,浏览器认识的规则. 2.开发者: 学习Html规则 开发后台程序: - 写Html文件(充当模板的作用) ****** - 数据库获取数据,然后替换到html文件的指定位置(W ...