計算兩個數字或字符串列表之間的差異。
用法
tf.compat.v1.setdiff1d(
x, y, index_dtype=tf.dtypes.int32, name=None
)參數
-
x一個Tensor。一維。要保持的值。 -
y一個Tensor。必須與x具有相同的類型。一維。要刪除的值。 -
out_idx一個可選的tf.DType來自:tf.int32, tf.int64。默認為tf.int32。 -
name操作的名稱(可選)。
返回
-
Tensor對象的元組(out,idx)。 -
out一個Tensor。具有與x相同的類型。 -
idxTensor類型為out_idx。
給定一個列表 x 和一個列表 y ,此操作返回一個列表 out ,它表示 x 中但不在 y 中的所有值。返回的列表 out 的排序順序與 x 中出現的數字相同(保留重複項)。此操作還返回一個列表 idx,它表示 x 中每個 out 元素的位置。換一種說法:
out[i] = x[idx[i]] for i in [0, 1, ..., len(out) - 1]
例如,給定這個輸入:
x = [1, 2, 3, 4, 5, 6]
y = [1, 3, 5]
此操作將返回:
out ==> [2, 4, 6]
idx ==> [1, 3, 5]
相關用法
- Python tf.compat.v1.set_random_seed用法及代碼示例
- Python tf.compat.v1.strings.length用法及代碼示例
- Python tf.compat.v1.scatter_min用法及代碼示例
- Python tf.compat.v1.summary.merge用法及代碼示例
- Python tf.compat.v1.size用法及代碼示例
- Python tf.compat.v1.scatter_add用法及代碼示例
- Python tf.compat.v1.summary.FileWriter用法及代碼示例
- Python tf.compat.v1.scatter_div用法及代碼示例
- Python tf.compat.v1.space_to_batch用法及代碼示例
- Python tf.compat.v1.string_split用法及代碼示例
- Python tf.compat.v1.squeeze用法及代碼示例
- Python tf.compat.v1.sparse_to_dense用法及代碼示例
- Python tf.compat.v1.sparse_segment_sum用法及代碼示例
- Python tf.compat.v1.scatter_update用法及代碼示例
- Python tf.compat.v1.sparse_split用法及代碼示例
- Python tf.compat.v1.string_to_number用法及代碼示例
- Python tf.compat.v1.saved_model.simple_save用法及代碼示例
- Python tf.compat.v1.scatter_nd_sub用法及代碼示例
- Python tf.compat.v1.sparse_reduce_max用法及代碼示例
- Python tf.compat.v1.shape用法及代碼示例
注:本文由純淨天空篩選整理自tensorflow.org大神的英文原創作品 tf.compat.v1.setdiff1d。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。
