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. Django之CBV源码解析

    l链接跳转:https://www.cnblogs.com/hnlmy/p/9662798.html 以及https://www.cnblogs.com/hnlmy/p/10603999.html

  2. [完美]原生JS获取浏览器版本判断--支持Edge,IE,Chrome,Firefox,Opera,Safari,以及各种使用Chrome和IE混合内核的浏览器

    截至自2017-08-11,支持现世已出的几乎所有PC端浏览器版本判断. 受支持的PC端浏览器列表: Edge IE Chrome Firefox Opera Safari QQ浏览器 360系列浏览 ...

  3. 【题解】Luogu P2730 魔板

    蒟蒻的第一道蓝题--好像也没有蓝的程度 一篇无STL的超弱题解(入门写法无误了QAQ 传送门 很经典的一道BFS 这是初始状态. 操作A 操作B 操作C 思路1 不使用cantor展开的情况 1. 对 ...

  4. cron笔记

    以前以为添加计划任务就是crontab -e来添加,知道今天偶然发现了/etc/cron.d目录,才发现事情没有那么简单.. crontab -e命令编辑的文件是保存在/var/spool/cron/ ...

  5. oracle insert、append、parallel、随后查询的redo与磁盘读写

    SQL> set autotrace traceonly statistics; SQL> insert into big_table_dir_test1 select * from bi ...

  6. [c/c++] programming之路(17)、高级指针

    一.二级指针 二级指针的作用:1.函数改变外部变量指针2.外挂改变一个指针的值 #include<stdio.h> #include<stdlib.h> void main() ...

  7. P3649 [APIO2014]回文串

    思路 回文自动机 回文自动机的fail[i]就是编号为i的这个字符串的最长的回文后缀的编号,然后len[i]表示编号为i的回文串的长度,cnt[i]表示编号为i的回文串的出现次数 然后trans边就是 ...

  8. Matlab Code for Visualize the Tracking Results of OTB100 dataset

    Matlab Code for Visualize the Tracking Results of OTB100 dataset 2018-11-12 17:06:21 %把所有tracker的结果画 ...

  9. Bytom 移动端钱包SDK FAQ

    比原链移动端钱包SDK项目地址:https://github.com/Bytom-Community/Bytom-Mobile-Wallet-SDK 1.客户端钱包SDK需要实现哪些功能? 创建密钥. ...

  10. Spring中 @Autowired标签与 @Resource标签

    spring不但支持自己定义的@Autowired注解,还支持由JSR-250规范定义的几个注解,如:@Resource. @PostConstruct及@PreDestroy. @Autowired ...