tf.reduce_sum() and tf.where()的用法
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()的用法的更多相关文章
- tf.reduce_sum tensorflow维度上的操作
tensorflow中有很多在维度上的操作,本例以常用的tf.reduce_sum进行说明.官方给的api reduce_sum( input_tensor, axis=None, keep_dims ...
- tf.trainable_variables() and tf.all_variables()
tf.trainable_variables() 返回的是 所有需要训练的变量列表 tf.all_variables() 返回的是 所有变量的列表 v = tf.Variable(0, name=' ...
- 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 ...
- TensorFlow函数:tf.reduce_sum
tf.reduce_sum 函数 reduce_sum ( input_tensor , axis = None , keep_dims = False , name = None , reducti ...
- tf.concat, tf.stack和tf.unstack的用法
tf.concat, tf.stack和tf.unstack的用法 tf.concat相当于numpy中的np.concatenate函数,用于将两个张量在某一个维度(axis)合并起来,例如: a ...
- tf.reduce_sum函数
>>> x=[[1,2,3],[23,13,213]] >>> xx=tf.reduce_sum(x) >>> sess.run(xx) 255 ...
- tf.reduce_sum()_tf.reduce_mean()_tf.reduce_max()
根据官方文档: reduce_sum应该理解为压缩求和,用于降维 tf.reduce_sum(input_tensor,axis=None,keepdims=None,name=None,reduct ...
- 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 ...
- 【转载】 tf.ConfigProto和tf.GPUOptions用法总结
原文地址: https://blog.csdn.net/C_chuxin/article/details/84990176 -------------------------------------- ...
随机推荐
- C++ this指针的理解和作用
01 C++ 程序到 C 程序的翻译 要想理解 C++ 的 this 指针,我们先把下面的 C++ 代码转换成 C 的代码 class Car { public: int m_price; // 成员 ...
- CSS3/CSS之居中解析(水平+垂直居中、水平居中,垂直居中)
首先,我们来看下垂直居中: (1).如果是单行文本,则可以设置的line-height的数值,让其等于父级元素的高度! <!DOCTYPE html> <html lang=&quo ...
- Linux下用户管理:创建用户指定密码
首先我们来了解下Linux下用户管理的概念: 如上图所示,左边的一列表示用户名,中间的一列表示用户组,最右边的一列表示的是家目录.用户名我们这里处于简单就,添加了root,xm,xh三个用户.用户组和 ...
- 免sdk实现微信/支付宝转账打赏功能
版权声明:本文为xing_star原创文章,转载请注明出处! 本文同步自http://javaexception.com/archives/162 近期发现了一个很好的开源项目,可以给自己的app添加 ...
- Android O的通知渠道适配
在 Android O 以后,Google引入了通知通道的概念,如果目标API大于 Android O ,不直指定通知渠道是不能发送通知的. 这里放一个我写好的通知方法,大家可以适当的改改再用,*当 ...
- BayaiM__linux双网卡绑定文档
BayaiM__linux双网卡绑定文档 开门贱山:以下内容纯属原创,如有雷同,爱咋咋滴吧~~!!—————————————————————————————————————————— 1,备份网卡信息 ...
- classmethod,staticmethod,反射,魔法方法,单例模式
目录 classmethod staticmethod instance issubclass 反射 hasatter getatter setatter delatter 魔法方法 单例模式 什么是 ...
- AtCoder Beginner Contest 145
传送门 A - Circle 签到. B - Echo 签到到. C - Average Length 要卡下精度,可用二分或者long double来搞. Code /* * Author: hey ...
- Appium左右、上下滑动(Java)
网上很多文章都说用swipe来左右滑动,你把代码一贴,结果报错,看半天,原来是java-client中swipe早就被废除了!!!下面介绍一种Java写法来左右上下滑动: 首先,创建一个Swipe类 ...
- scanf函数和cin的区别、类的数组、C++排序函数
给定n个字符串,将这n个字符串按照字典序进行排列,此处用排列函数是C++的库函数sort,产生如下两个疑问,望大佬解答 #include <iostream> #include <a ...