tensorflow库和numpy库中的相关函数
来源:互联网 发布:xp网络连接图标不见了 编辑:程序博客网 时间:2024/06/15 08:50
tensorflow:
- tf.placeholder(shape=[2,10],dtype=tf.float32);//占位符操作,类型为[[2,10]的二维张量
- tf.gather(params,indices);表示从params中根据indices索引获取相应的滑块,举例如下:
tf.expand_dims(tensor,axis);表明在制定位置对数据进行扩展一个维度,且扩展的这个维度一定为1维,如t2的shape为[2,3,4],expand_dims(t2,0),则其维度变为[1,2,3,4];如果为expand_dims(t2,3),则其维度为[2,3,4,1];
temp=tf.range(0,10)//表明生成0..9的10个整数张量temp2=tf.gather(temp,[0,1,9])sess=tf.Session()sess.run(temp)sess.close()
temp2的值为array([0,1,5],dtype=int32),表明tf.gather指示根据indices索引从params中找寻滑块;
tf.argmax(input,axis);//获取制定列的最大值索引tf.reduce_sum(input_tensor,axis,keep_dims=True);//求和操作,如果添上axis列的话,则是求制定列的和
- tf.squeeze(input,axis);//从input张量中移除掉所有维度为1的维度,如果axis也被声明的话,则从制定的列中移除掉值为1的维度,如tensor的shape是[1,2,3,5],直接调用squeeze函数的话,则会移除掉第一维度的维度,返回的shape为[2,3,5],如果制定axis的话则首先得保证axis维度的维度一定为1;
numpy
np.ceil:解释起来有些麻烦,可以参照如下代码理解:
a = np.array([-1.7, -1.5, -0.2, 0.2, 1.5, 1.7, 2.0])np.ceil(a)array([-1., -1., -0., 1., 2., 2., 2.])
np.argmax(array,axis,out);表示返回某一列最大值的索引,并将起天降到out数组中,如果out数组提供了的话,否则指示返回索引即可,见如下代码:
a=[[1,2,3],[2,3,4],[9,7,8]]b=np.argmax(a,0)
返回值为array([2,2,0]),np.argmax中的axis表示行和列,0代表列,1代表行
创建数组的方法:
from numpy import *a=array([1,2,3],[4,6,7],dtype=float32)b=zeros([3,4],dtype=int16)c=arange(10,30,5)==>[10,15,20,25]c_val=c.reshape(3,2)
阅读全文
0 0
- tensorflow库和numpy库中的相关函数
- python numpy库中的数据存取和函数
- python自带的sum()函数和numpy库中的sum()函数的区别
- TensorFlow, numpy中的broadcast机制
- numpy 相关函数
- Numpy库学习(三)numpy的随机函数,统计函数和梯度函数
- Python 中的numpy 库
- python中的numpy库的numpy.asarray
- python 的numpy库中的mean()函数用法
- numpy,theano中的函数
- numpy中的tile函数
- numpy中的tile函数
- numpy中的tile函数
- Numpy中的transpose函数
- Numpy中的ravel_multi_index函数
- numpy中的tile函数
- numpy中的常用函数
- numpy中的tile函数
- Redis数据类型list类型常用命令
- HTTP协议知多少-关于http1.x、http2、SPDY的相关知识
- 使用性能API快速分析web前端性能
- 《数据库SQL实战》查找当前薪水详情以及部门编号dept_no
- HTTP协议解析
- tensorflow库和numpy库中的相关函数
- 综合收集
- TITAN引擎【0.1.0】版本发布
- 【几维安全】移动安全形势严峻:企业数字化转型,解决安全问题刻不容缓!
- 内外网同时使用静态路由设置
- maven常用命令以及下载的原理
- Ubiquitous Religions
- Swift 3.0
- python——sorted函数、sort函数以及operator.itemgetter的使用