TensorFlow学习笔记(十六)tf.random_normal

W1 = tf.Variable(tf.random_normal([3, 3, 1, 32], stddev=0.01)),对于函数 tf.random_normal解释如下:
tf.random_normal
tf.random_normal(shape, mean=0.0, stddev=1.0, dtype=tf.float32, seed=None, name=None)

Outputs random values from a normal distribution.

Args:

shape: A 1-D integer Tensor or Python array. The shape of the output tensor.用一个list表示产出的Tensor的形状
mean: A 0-D Tensor or Python value of type dtype. The mean of the normal distribution.均值
stddev: A 0-D Tensor or Python value of type dtype. The standard deviation of the normal distribution.标准差
dtype: The type of the output.数据类型
seed: A Python integer. Used to create a random seed for the distribution. See set_random_seed for behavior.
name: A name for the operation (optional).
Returns:

A tensor of the specified shape filled with random normal values.
例子:
import tensorflow as tf
import matplotlib.pyplot as plt

a = tf.random_normal([2,10],mean=0,stddev=1)
sess = tf.Session()
out = sess.run(a)
print(out)
x, y = out
print(x)
print(y)
plt.scatter(x,y)
plt.show()
sess.close()

结果:
[[ 0.83045179 -0.57167524 -1.86910343 ...,  0.71390063  1.04222453
   0.91866982]
 [ 1.00804222 -0.4957338   0.63204587 ..., -0.69086301  0.71216989  0.02643   ]]
[ 0.83045179 -0.57167524 -1.86910343  0.44209865 -1.05302727  0.64135087
  1.89882576  0.71390063  1.04222453  0.91866982]
[ 1.00804222 -0.4957338   0.63204587 -0.55980664  0.56179941  0.27138013
  0.26539552 -0.69086301  0.71216989  0.02643   ]

  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Soyoger

听说打赏的都进了福布斯排行榜。

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值