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的一些函数的更多相关文章

  1. Tensorflow Batch normalization函数

    Tensorflow Batch normalization函数 觉得有用的话,欢迎一起讨论相互学习~Follow Me 参考文献 stackoverflow上tensorflow实现BN的不同函数的 ...

  2. tensorflow.nn.bidirectional_dynamic_rnn()函数的用法

    在分析Attention-over-attention源码过程中,对于tensorflow.nn.bidirectional_dynamic_rnn()函数的总结: 首先来看一下,函数: def bi ...

  3. TensorFlow常用的函数

    TensorFlow中维护的集合列表 在一个计算图中,可以通过集合(collection)来管理不同类别的资源.比如通过 tf.add_to_collection 函数可以将资源加入一个 或多个集合中 ...

  4. Tensorflow常用的函数:tf.cast

    1.tf.cast(x,dtype,name) 此函数的目的是为了将x数据,准换为dtype所表示的类型,例如tf.float32,tf.bool,tf.uint8等 example:  import ...

  5. [转载]Tensorflow 的reduce_sum()函数的axis,keep_dim这些参数到底是什么意思?

    转载链接:https://www.zhihu.com/question/51325408/answer/125426642来源:知乎 这个问题无外乎有三个难点: 什么是sum 什么是reduce 什么 ...

  6. 查询tensorflow中的函数用法

    一下均在ubuntu环境下: (1)方法一,使用help()函数: 比如对于tf.placeholder(),在命令行中输入import tensorflow as tf , help(tf.plac ...

  7. TensorFlow激活函数+归一化-函数

    激活函数的作用如下-引用<TensorFlow实践>: 这些函数与其他层的输出联合使用可以生成特征图.他们用于对某些运算的结果进行平滑或者微分.其目标是为神经网络引入非线性.曲线能够刻画出 ...

  8. TensorFlow图像预处理-函数

    更多的基本的API请参看TensorFlow中文社区:http://www.tensorfly.cn/tfdoc/api_docs/python/array_ops.html 下面是实验的代码,可以参 ...

  9. TensorFlow卷积层-函数

    函数1:tf.nn.conv2d是TensorFlow里面实现卷积的函数,实际上这是搭建卷积神经网络比较核心的一个方法 函数原型: tf.nn.conv2d(input,filter,strides, ...

  10. TensorFlow中assign函数

    tf.assign assign ( ref , value , validate_shape = None , use_locking = None , name = None ) 定义在:tens ...

随机推荐

  1. C Primer Plus(第六版)中文版 中的错误1

    #include<stdio.h> #include<stdlib.h> #include<string.h> #define TSIZE 45 struct fi ...

  2. Redis学习笔记1 -- 单机环境时分布式锁的使用

    使用第三方开源组件Jedis实现Redis客户端,且只考虑Redis服务端单机部署的场景. 前言 分布式锁一般有三种实现方式:1. 数据库乐观锁:2. 基于Redis的分布式锁:3. 基于ZooKee ...

  3. AngularJs 延时器、计时器

    1.$timeout延时器 apptest.controller("main",function($scope,$timeout){ $scope.pink="pink& ...

  4. sublime_key 快捷键

    1.Ctrl+H :查找替换 2.Ctrl+D :选择游标所在单词,连续Ctrl+D 实现多行选择(选择与第一次选择相同的单词) 3.Ctrl+K Ctrl+D 跳过当前选择,选择下一个 4.Ctrl ...

  5. Linux基础之-shell script(变量,运算符,流程控制,函数)

    一.shell script Shell 脚本(shell script),是一种为shell编写的脚本程序.业界所说的shell通常都是指shell脚本,但读者朋友要知道,shell和shell s ...

  6. Redis 实现分布式锁

    前言 分布式锁一般有三种实现方式:1. 数据库乐观锁:2. 基于Redis的分布式锁:3. 基于ZooKeeper的分布式锁.本篇博客将介绍第二种方式,基于Redis实现分布式锁.虽然网上已经有各种介 ...

  7. FiddLer模拟post不成功的解决办法

    开始用fiddler抓app包,后来想模拟一下post请求,发现一直接受不到,wtf? 默认的header是类似这样的 User-Agent: Fiddler Host: localhost Cont ...

  8. bitekind

    xrp这个人到SNT家坐在IOST的椅子上,喝着THETA. 武之巅峰,是孤独,是寂寞,是漫漫求索,是高处不胜寒    逆境中成长,绝地里求生,不屈不饶,才能堪破武之极道.    凌霄阁试炼弟子兼扫地 ...

  9. androidwebview timeout

    public class MyWebViewClient extends WebViewClient { boolean timeout; public MyWebView() { timeout = ...

  10. 【Leetcode】【Medium】Multiply Strings

    Given two numbers represented as strings, return multiplication of the numbers as a string. Note: Th ...