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 ...
随机推荐
- C++运行符重载、友元函数
Complex.h #pragma once #include <iostream> using namespace std; //表示一个复数 class Complex { priva ...
- golang学习之文件上传
首先是上传页面upload.html: <!doctype html> <html> <head> <meta charset="utf-8&quo ...
- dategrid快速录入一行数据的一波操作
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...
- POJ1651 Multiplication Puzzle(相邻乘积之和最小,区间DP)
http://blog.csdn.net/libin56842/article/details/9747021 http://www.cnblogs.com/devil-91/archive/2012 ...
- 关于display:inline-block布局导致错位问题分析
移动端设计稿需求是这样的,如下图: 未知的几个头像从左至右并行居中排列. 一般可能直接使用float,但是设计图要求头像排列始终是居中的,于是想到要让它们成为行内元素,然后可使用的方法有flex bo ...
- 【Android】13.0 UI开发(四)——列表控件RecyclerView的横向布局排列实现
1.0 新建项目,由于ListView的局限性,RecyclerView是一种很好取代ListView的控件,可以灵活实现多种布局. 2.0 新建项目RecyclerviewTest,目录如下: 3. ...
- (C# 正则表达式)判断匹配, 提取字符串或数值
string s = "if ( \"ch\" == \"os\" ) "; string pattern = @"if\s*\( ...
- 万网知您所需,“域”众不同--.link/.love/.help等一大波新顶级域来袭!
万网在新顶级域市场再次发力,一大波域名界的小鲜肉新鲜上线,价格优惠,限时低至9元起,更有丰富的可注册资源. 一下,即刻世界,用记录生活,用观看世界, 用和做最好的! 新上线的个性化新顶级域价格如下: ...
- Genymotion模拟器拖入文件报An error occured while deploying the file的错误
今天需要用到资源文件,需要将资源文件拖拽到sd卡中,但老是出现这个问题: 资源文件拖不进去genymotion.查看了sd的DownLoad目录,确实没有成功拖拽进去. 遇到这种问题的,我按下面的思路 ...
- 一、CSS实现横列布局的方法总结
一.使用float实现横列布局的方法 如下面所示:DIV1和DIV2都可以选择向左或者向右浮动50%来实现展示在同一行 div1 div2 实现下面图片中布局的css样式如下: 分析: 1.第一行第一 ...