tensorflow的一些函数
1.tf.constant(value,dtype=None,shape=None,name='Const')
注意这个函数创造的是一个常数tensor,而不是一个具体的常数
value:即可以是list,也可以是value
dtype:对应生成的tensor里的元素的类型
# Constant 1-D Tensor populated with value list.
tensor = tf.constant([1, 2, 3, 4, 5, 6, 7]) => [1 2 3 4 5 6 7] 注意这种直接加入list的情况 # Constant 2-D tensor populated with scalar value -1.
tensor = tf.constant(-1.0, shape=[2, 3]) => [[-1. -1. -1.]
[-1. -1. -1.]]
对于value给tensor,并不是不能shape形状,如果shape出来value中的元素不够用时,就以最后一个元素重复出现填充至满足形状。
以下实例:
>>> sess = tf.InteractiveSession() >>> a = tf.constant([1,2,3],shape = [6])
>>> b = tf.constant([1,2,3],shape = [3,2])
>>> c = tf.constant([1,2,3],shape = [2,3]) >>> print sess.run(a)
[1 2 3 3 3 3]
>>> print sess.run(b)
[[1 2]
[3 3]
[3 3]]
>>> print sess.run(c)
[[1 2 3]
[3 3 3]]
2.tf.truncated_normal(shape,mean=0.0,stddev=1.0,dtype=tf.float32,seed=None,name=None)
这个函数是从截断的正态分布产生随机数
mean:均值
stddev:标准差
tensorflow的一些函数的更多相关文章
- Tensorflow Batch normalization函数
Tensorflow Batch normalization函数 觉得有用的话,欢迎一起讨论相互学习~Follow Me 参考文献 stackoverflow上tensorflow实现BN的不同函数的 ...
- tensorflow.nn.bidirectional_dynamic_rnn()函数的用法
在分析Attention-over-attention源码过程中,对于tensorflow.nn.bidirectional_dynamic_rnn()函数的总结: 首先来看一下,函数: def bi ...
- TensorFlow常用的函数
TensorFlow中维护的集合列表 在一个计算图中,可以通过集合(collection)来管理不同类别的资源.比如通过 tf.add_to_collection 函数可以将资源加入一个 或多个集合中 ...
- Tensorflow常用的函数:tf.cast
1.tf.cast(x,dtype,name) 此函数的目的是为了将x数据,准换为dtype所表示的类型,例如tf.float32,tf.bool,tf.uint8等 example: import ...
- [转载]Tensorflow 的reduce_sum()函数的axis,keep_dim这些参数到底是什么意思?
转载链接:https://www.zhihu.com/question/51325408/answer/125426642来源:知乎 这个问题无外乎有三个难点: 什么是sum 什么是reduce 什么 ...
- 查询tensorflow中的函数用法
一下均在ubuntu环境下: (1)方法一,使用help()函数: 比如对于tf.placeholder(),在命令行中输入import tensorflow as tf , help(tf.plac ...
- TensorFlow激活函数+归一化-函数
激活函数的作用如下-引用<TensorFlow实践>: 这些函数与其他层的输出联合使用可以生成特征图.他们用于对某些运算的结果进行平滑或者微分.其目标是为神经网络引入非线性.曲线能够刻画出 ...
- TensorFlow图像预处理-函数
更多的基本的API请参看TensorFlow中文社区:http://www.tensorfly.cn/tfdoc/api_docs/python/array_ops.html 下面是实验的代码,可以参 ...
- TensorFlow卷积层-函数
函数1:tf.nn.conv2d是TensorFlow里面实现卷积的函数,实际上这是搭建卷积神经网络比较核心的一个方法 函数原型: tf.nn.conv2d(input,filter,strides, ...
- TensorFlow中assign函数
tf.assign assign ( ref , value , validate_shape = None , use_locking = None , name = None ) 定义在:tens ...
随机推荐
- Asp.net MVC5系列——第一个项目
转自http://www.cnblogs.com/wolf-sun/p/3888160.html 概述 在这一部分我们添加一个新的控制器HelloWorldController类,以便使用视图来向客户 ...
- Cheatsheet: 2017 05.01 ~05.31
Web Configuring Your .npmrc for an Optimal Node.js Environment Web Developer Security Checklist HTTP ...
- SpringCloud实战之初级入门(一)— eureka注册中心
目录 写在前面 1.资料目录 2.环境介绍 3.eureka注册中心 3.1 创建工程 3.2 启动工程 5.eureka注册中心集群高可用 6.结语 7.一点点重要的事情 写在前面 我在软件行业浸泡 ...
- 多文件上传CommonsMultipartResolver
1.CommonsMultipartResolver是spring里面提供的一个上传方式,效率我不知道,但是加入spring容器管理还是很不错的. 2.先看依赖包pom.xml <project ...
- aspose words做插入压缩后图片到Word文档中
最近用aspose words做导出Word的功能,发现图片的导出有点难受,一开始是这样写的 Document doc = new Document("D:\\Template.docx&q ...
- 【转】百亿级实时大数据分析项目,为什么不用Hadoop?
百亿数量级的大数据项目,软硬件总体预算只有30万左右,需求是进行复杂分析查询,性能要求多数分析请求达到秒级响应. 遇到这样的项目需求,预算不多的情况,似乎只能考虑基于Hadoop来实施. ...
- SQL SERVER 2012修改数据库名称(包括 db.mdf 名称的修改)
假设原来数据库名为db,附加数据库为db.mdf和db_log.ldf.需要改成dbt,及dbt.mdf和dbt_log.ldf. 步骤: .首先把原来的数据库进行备份(选择数据库->右键-&g ...
- [Java反射基础一]Class类的使用
任何一个类都是Class类的实例对象,这个实例对象有三种表示方式 第一种表示方式(任何一个类都有一个隐含的静态成员变量class): Class c1 = Foo.class; 第二种表示方式(已知该 ...
- mysql通过一张表更新另一张表
在mysql中,通过一张表的列修改另一张关联表中的内容: 1: 修改1列 update student s, city c set s.city_name = c.name where s.city ...
- select下拉框选择字体大小
效果: 结合Bootstrap.jQuery和ES6字符串模板与箭头函数使用JavaScript DOM操作动态添加option,随着option:selected选中的字号而改变相应的字体大小 代码 ...