1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
| """ Created on Wed Sep 15 22:31:23 2021
@author: fshao """
import tensorflow as tf
def printMatrix(matrix): print('===========================') with tf.Session() as sess: print(sess.run(matrix))
t_1 = tf.constant(4)
t_2 = tf.constant([4,3,2])
t_3 = tf.zeros([4,5],tf.int32) t_4 = tf.ones([4,5],tf.int32)
t_5 = tf.linspace(0.0,10.0,11)
t_6 = tf.range(10)
t_7 = tf.random_normal([2,3],mean=2.0,stddev=1.0,seed=12)
t_8 = tf.truncated_normal([1,5],stddev=2,seed=12)
t_9 = tf.random_uniform([5,5],maxval=4,seed=12)
t_10 = tf.random_crop(t_9,[2,3],seed=12)
t_11 = tf.random_shuffle(t_10)
tf.set_random_seed(54)
weight = tf.Variable(tf.random_normal([100,100],stddev=2)) bias = tf.Variable(tf.zeros([100]),name = 'biases')
x = tf.placeholder("float") y = 2 * x data = tf.random_uniform([4,5],10) with tf.Session() as sess: x_data = sess.run(data) print(sess.run(y,feed_dict={x:x_data}))
|