import tensorflow as tf
#声明一个常量
i = tf.constant(1)
print(i)
#声明一个向量
v = tf.constant([1,2,3,4,5])
v1 = tf.constant([2,3,4,5,6])
print(v)
#3*5 matrix 0
v2 = tf.zeros([3,5],tf.int32)
print(v2)
#5*6 matrix 1
v3 = tf.ones([5,6],tf.float32)
print(v3)
#
v4 = tf.linspace(0.0,10.0,5)
print(v4)
v5 = v+v1
with tf.Session():
print(v4.eval())
print(v2.eval())
print(v5.eval())
网友评论