tf生成随机数

import tensorflow as tf

sess = tf.InteractiveSession()

### 生成符合正态分布的随机值
# tf.random_normal(shape, mean, stddev, dtype, seed, name)
a = tf.random_normal([2, 3], name='a')
print(a.eval())
# [[-1.2077953 -0.69333565 -0.10252991]
# [ 0.51914424 0.7754795 -0.02618051]] ### 生成截断的正态分布的随机值
## 只保留[mean - 2stddev, mean + 2stddev]内的随机数
# tf.truncated_normal(shape, mean, stddev, dtype, seed, name)
b = tf.truncated_normal([2, 3], name='b')
print(b.eval())
# [[-1.8038174 1.521785 0.33182728]
# [ 1.0274183 -0.39916983 -0.50485927]] ### 生成均匀分布的随机数
# tf.random_uniform(shape, minval, maxval, dtype, seed, name)
c = tf.random_uniform([2, 3], name='c')
print(c.eval())
# [[0.6636964 0.20990396 0.44687605]
# [0.64548564 0.22155988 0.19247997]] ### 按行乱序
# tf.random_shuffle(value, dtype, name)
d = tf.random_shuffle([[1, 2], [3, 2]], name='d')
print(d.eval())

tf 随机数的更多相关文章

  1. 深度学习原理与框架-Tensorflow基本操作-变量常用操作 1.tf.random_normal(生成正态分布随机数) 2.tf.random_shuffle(进行洗牌操作) 3. tf.assign(赋值操作) 4.tf.convert_to_tensor(转换为tensor类型) 5.tf.add(相加操作) tf.divide(相乘操作) 6.tf.placeholder(输入数据占位

    1. 使用tf.random_normal([2, 3], mean=-1, stddev=4) 创建一个正态分布的随机数 参数说明:[2, 3]表示随机数的维度,mean表示平均值,stddev表示 ...

  2. tensorflow 生成随机数 tf.random_normal 和 tf.random_uniform 和 tf.truncated_normal 和 tf.random_shuffle

    ____tz_zs tf.random_normal 从正态分布中输出随机值. . <span style="font-size:16px;">random_norma ...

  3. tensorflow生成随机数的操作 tf.random_normal & tf.random_uniform & tf.truncated_normal & tf.random_shuffle

    tf.random_normal 从正态分布输出随机值. random_normal(shape,mean=0.0,stddev=1.0,dtype=tf.float32,seed=None,name ...

  4. Tensorflow图级别随机数设置-tf.set_random_seed(seed)

    tf.set_random_seed(seed) 可使得所有会话中op产生的随机序列是相等可重复的. 例如: tf.set_random_seed(1234) a = tf.random_unifor ...

  5. centos7 shell脚本实现随机数

    questions: 1.随机数如何获得 2.如何确定随机值的大小是我们所需要的 answers: 1.目前可以通过获取系统时间的毫秒数来得到,毕竟毫秒数还是变化比较快的 可以看到这个速度还是变化很快 ...

  6. tf多线程读取数据

    多线程读取数据的机制 tf中多线程读取数据跟常规的python多线程思路一致,是基于Queue的多线程编程. 主线程读取数据,然后计算,在读数据这部分有两个线程,一个线程读取文件名,生成文件名队列,另 ...

  7. tensorflow中 tf.train.slice_input_producer 和 tf.train.batch 函数(转)

    tensorflow数据读取机制 tensorflow中为了充分利用GPU,减少GPU等待数据的空闲时间,使用了两个线程分别执行数据读入和数据计算. 具体来说就是使用一个线程源源不断的将硬盘中的图片数 ...

  8. tf.truncated_normal

    tf.truncated_normal truncated_normal( shape, mean=0.0, stddev=1.0, dtype=tf.float32, seed=None, name ...

  9. TensorFlow:tf.contrib.layers.xavier_initializer

    xavier_initializer( uniform=True, seed=None, dtype=tf.float32 ) 该函数返回一个用于初始化权重的初始化程序 “Xavier” .这个初始化 ...

随机推荐

  1. 视图模型-Lambda表达式

    EF中通过改变实体对象达到操作数据库表数据的目的,在对数据库实体操作时,肯定少不了和Linq.Lambda打交道,熟悉SQL的话,上手 Linq并不难,from in where select... ...

  2. IntelliJ Idea 使用笔记

    1. IntelliJ Idea解决Could not autowire. No beans of 'xxxx' type found的错误提示. 原因可能有两个,第一个是IntellijIDEA本身 ...

  3. 普通文件的上传(表单上传和ajax文件异步上传)

    一.表单上传: html客户端部分: <form action="upload.ashx" method="post" enctype="mul ...

  4. EDK II之Device Path

    UEFI中通过Device Path来描述设备的路径,一个完整的路径由多个Device Path Nodes组成. 下面通过输入设备的路径作为例子: PNP0A03 – PCI Host Bridge ...

  5. sublime package control INSTALLATION

    Simple The simplest method of installation is through the Sublime Text console. The console is acces ...

  6. jQuery 位置

    jQuery 位置 // 默认窗口 $(window) // 查看.指定标签上下滚轮的位置数 $('#id').scrollTop() // 设置.指定标签上下滚轮的位置数 $('#id').scro ...

  7. java.lang.IllegalArgumentException: An invalid domain [.test.com] was specified for this cookie解决方法

    当项目中使用单点登录功能时,通常会使用cookie进行信息的保存,这样就可以在多个子域名上存取用户信息. 比如有三个domain分别为test.com,cml.test.com,b.test.com这 ...

  8. postman+linux+pistache的http通信过程

    一.pistache配置 1.安装cmake[https://www.cnblogs.com/judes/p/10327638.html] 2.下载pistache[git:https://githu ...

  9. Spring 学习——Spring AOP——AOP配置篇Aspect、Pointcut

    Schena——based AOP 声明 Spring所有的切面和通知器都必须放在一个<aop:config>标签内,可以同时配置多个<aop:config>元素. 每一个&l ...

  10. 最短路模板|堆优化Dijkstra,SPFA,floyd

    Ⅰ:Dijkstra单源点最短路 1.1Dijkstra const int MAX_N = 10000; const int MAX_M = 100000; const int inf = 0x3f ...