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 ]
例子:
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 ]