TensorFlow学习笔记(十六)tf.random_normal
生活随笔
收集整理的這篇文章主要介紹了
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?? ]
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?? ]
總結
以上是生活随笔為你收集整理的TensorFlow学习笔记(十六)tf.random_normal的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 相似度和相异度、常用距离度量、余弦相似度
- 下一篇: TensorFlow学习笔记(十七)tf