import tensorflow as tf
import numpy as np
sess=tf.Session()
a=np.ones((5,6))
c=tf.cast(tf.reduce_sum(a, axis=1),tf.bool) # tf.reduce_sum 表示按照axis方向求和
c=sess.run(c)
print('c=',c)
print('c.shape',c.shape)
k=tf.where(c) # 因为返回的是索引值为列表中
k=sess.run(k)
print('k=',k)
print('k.shape=',k.shape)
k_compare=tf.where(c)[:, 0]
k_compare=sess.run(k_compare)
print('k_compare=',k_compare)
print('k_compare.shape=',k_compare.shape) 结果如下:

tf.reduce_sum() and tf.where()的用法的更多相关文章

  1. tf.reduce_sum tensorflow维度上的操作

    tensorflow中有很多在维度上的操作,本例以常用的tf.reduce_sum进行说明.官方给的api reduce_sum( input_tensor, axis=None, keep_dims ...

  2. tf.trainable_variables() and tf.all_variables()

    tf.trainable_variables()  返回的是 所有需要训练的变量列表 tf.all_variables() 返回的是 所有变量的列表 v = tf.Variable(0, name=' ...

  3. 1、求loss:tf.reduce_mean(tf.nn.softmax_cross_entropy_with_logits(logits, labels, name=None))

    1.求loss: tf.reduce_mean(tf.nn.softmax_cross_entropy_with_logits(logits, labels, name=None)) 第一个参数log ...

  4. TensorFlow函数:tf.reduce_sum

    tf.reduce_sum 函数 reduce_sum ( input_tensor , axis = None , keep_dims = False , name = None , reducti ...

  5. tf.concat, tf.stack和tf.unstack的用法

    tf.concat, tf.stack和tf.unstack的用法 tf.concat相当于numpy中的np.concatenate函数,用于将两个张量在某一个维度(axis)合并起来,例如: a ...

  6. tf.reduce_sum函数

    >>> x=[[1,2,3],[23,13,213]] >>> xx=tf.reduce_sum(x) >>> sess.run(xx) 255 ...

  7. tf.reduce_sum()_tf.reduce_mean()_tf.reduce_max()

    根据官方文档: reduce_sum应该理解为压缩求和,用于降维 tf.reduce_sum(input_tensor,axis=None,keepdims=None,name=None,reduct ...

  8. tf.nn.softmax & tf.nn.reduce_sum & tf.nn.softmax_cross_entropy_with_logits

    tf.nn.softmax softmax是神经网络的最后一层将实数空间映射到概率空间的常用方法,公式如下: \[ softmax(x)_i=\frac{exp(x_i)}{\sum_jexp(x_j ...

  9. 【转载】 tf.ConfigProto和tf.GPUOptions用法总结

    原文地址: https://blog.csdn.net/C_chuxin/article/details/84990176 -------------------------------------- ...

随机推荐

  1. PHP mysqli_kill MySQLi 函数

    mysqli_kill - 让服务器杀掉一个 MySQL 线程 语法:mysqli_kill ( mysqli $link , int $processid ) 本函数可以用来让服务器杀掉 proce ...

  2. HTTP:Web的基础

    一.HTTP:Web的基础 1.URI 每个Web服务器资源都有一个名字,这样客户端就可以说明它们感兴趣的资源是什么了.服务器资源名称被称为统一资源标识符(URI) URI有两种形式,分别为URL和U ...

  3. leaflet-webpack 入门开发系列一初探篇(附源码下载)

    前言 leaflet-webpack 入门开发系列环境知识点了解: node 安装包下载webpack 打包管理工具需要依赖 node 环境,所以 node 安装包必须安装,上面链接是官网下载地址 w ...

  4. Dynamics 365利用HTML页面创建实体记录并同步上传附件

    我是微软Dynamcis 365 & Power Platform方面的工程师罗勇,也是2015年7月到2018年6月连续三年Dynamics CRM/Business Solutions方面 ...

  5. Apache配置https

    Apache配置https 之前一直用的是Tomcat,今天突然接到任务要给Apache配置https证书,因为小程序要用.下面把过程列出来以备后续查看. 1.首先你得有ssl证书,没有的可以去购买, ...

  6. oracle通过impdp导入不同表用户、不同表空间的数据

    原创 tegwy 发布于2013-04-21 17:34:39 阅读数 46592 收藏 展开 impdp smtj2012/密码@localhost/devdb DIRECTORY=dump_dir ...

  7. C++:map用法及元素的默认值

    C++:map用法 一.map基本用法 键值对 第一个参数为键的类型,第二个参数为值的类型. 源代码 #include <iostream> #include <string> ...

  8. 如何让table中td与四周有间距

    如何让table中td与四周有间距 方法一 在td下再添加一个会计元素 <tr> <td>第2节</td> <td>语文</td> < ...

  9. 27.Java基础_多态

    父类对象引用子类对象: Animal a=new Cat(); 多态中的转型 public class Animal { public void eat(){ System.out.println(& ...

  10. R-时空可视化

    Robert J. Hijmans37 开发了 raster 包用于网格空间数据的读.写.操作.分析和建模,同时维护了空间数据分析的网站 https://www.rspatial.org Edzer ...