import tensorflow as tf zero=tf.zeros([3,4],tf.float32) with tf.Session() as sess: print(zero.eval())
运行结果:
[[0. 0. 0. 0.]
[0. 0. 0. 0.]
[0. 0. 0. 0.]]
import tensorflow as tf zero=tf.ones([3,4],tf.float32) with tf.Session() as sess: print(zero.eval())
运行结果:
[[1. 1. 1. 1.]
[1. 1. 1. 1.]
[1. 1. 1. 1.]]
shape:创建的数据的形状
mean:创建的数据的均值
stddev:创建的数据的标准差
指的是数值类型转换,如int32-->float32
import tensorflow as tf a=tf.cast([[1,2,3],[4,5,6]],tf.float32) with tf.Session() as sess: print(a.eval())
运行结果:
[[1. 2. 3.]
[4. 5. 6.]]
注解:
- int---->float的例子
注解:
- 矩阵按行、按列合并
注解:
- 用的最多的是矩阵的乘法,tf.matmul