下面程序段的执行结果为( )。import tensorflow as tfa = tf.range(6)a1 = tf.reshape(a, [2, 3])b = tf.constant([[7, 8, 9], [10, 11, 12]])b1 = tf.gather(b, axis=1, indices=[1, 2, 0])c = a1*b1print(c.numpy())
A.[[ 0 9 14] [33 48 50]]
B.[[ 0 8 0] [30 44 0]]
C.[[ 0 8 18] [30 44 60]]
D.[[ 0 9 16] [30 48 55]]
查看答案
对下列程序段的执行结果,描述错误的是( )。import tensorflow as tfx = tf.constant([1., 4., 9., 16.])pow(x, 0.5)
A.输出张量的shape为(1,)
B.pow(x, 0.5)的作用是对张量x逐元素求平方根
C.张量数据类型为float32
D.其结果为[1., 2., 3., 4.]
下列程序段的执行结果为( )。import tensorflow as tfa = tf.range(24)b = tf.reshape(a,[4,6])c = tf.gather_nd(b,[[0,0],[1,1],[2,2]])print(c.numpy())
A.[ 0 7 14]
B.[ 0 1 2]
C.[ 1 8 15]
D.[ 0 6 12]
执行下列程序段后,得到的结果是( )。import tensorflow as tfimport numpy as npa = tf.constant(np.arange(48).reshape(3,2,4,2))b =tf.random.shuffle(a)c = tf.constant(np.arange(8).reshape(2,4))d = a@cprint(d.shape)
A.(3, 2, 4, 4)
B.(3, 4, 4, 2)
C.(3, 4, 4)
D.(3, 2, 2, 2)
下列程序段的执行结果为( )。import tensorflow as tfimport numpy as npa = tf.constant([[1., 2., 3.],[4., 5., 6.]])b = tf.random.shuffle(a)c = tf.constant(np.arange(6), shape=(3,2) ,dtype=tf.float32)d = tf.reduce_mean(b@c, axis=0)e = tf.argmin(d,axis=0)print("d_value:",d.numpy())print("e_value:",e.numpy())
A.d_value: [25. 35.5]e_value: 0
B.d_value: [25. 35.5]e_value: 1
C.d_value: [50. 71.]e_value: 1
D.d_value: [25 35]e_value: 0