常用函式1

2022-06-20 20:42:12 字數 899 閱讀 5642

"""求沿指定維度的平均值、和(axis=1沿行向量方向)"""

x = tf.constant([[1, 2, 3], [2, 2, 3]])

print("x:", x)

print("mean of x:", tf.reduce_mean(x)) # 求x中所有數的均值

print("sum of x:", tf.reduce_sum(x, axis=1)) # 求每一行的和

"""切分張量的第一維度,生成特徵/標籤對,構建資料集"""

features = tf.constant([12, 23, 10, 17])

labels = tf.constant([0, 1, 1, 0])

dataset = tf.data.dataset.from_tensor_slices((features, labels))

for element in dataset:

print(element)

"""enumerate 列舉 enumerate(列表名)"""

seq = ['one', 'two', 'three']

for i, element in enumerate(seq):

print(i, element)

""""tf.argmax返回張量沿指定維度最大值的索引"""

test = np.array([[1, 2, 3], [2, 3, 4], [5, 4, 3], [8, 7, 2]])

print("test:\n", test)

print("每一列的最大值的索引:", tf.argmax(test, axis=0)) # 返回每一列最大值的索引

print("每一行的最大值的索引", tf.argmax(test, axis=1)) # 返回每一行最大值的索引

常用函式(1)

oracle中如何使用轉義字元 separch char chr 1 nvl string1,replace with 功能 如果string1為null,則nvl函式返回replace with的值,否則返回string1的值,如果兩個引數都為null 則返回null。注意事項 string1和r...

php常用函式(1)

今天看了書,總結下php常用函式 1.checkdate 日期驗證函式 功能 用來驗證乙個日期是否有效 語法 bool checkdate int month,int day,int year year的值是從1到32767 month的值是從1到12 day的值在給定的month所應具有的天數範圍...

隨記(1)常用函式

lists map返回列表 執行返回結果,組成列表 lists map fun x x,x end,a,b,c 結果 a,a b,b c,c lists filte返回列表 挑選符合的,組成列表 lists filter fun e is integer e end,q,2,a,4 結果 2,4 l...