當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


Tensorflow.js tf.util.shuffleCombo()用法及代碼示例

Tensorflow.js是一個開放源代碼庫,由Google開發,用於在瀏覽器或節點環境中運行機器學習模型以及深度學習神經網絡。

.util.shuffleCombo()函數用於在Fisher-Yates算法的幫助下按順序對兩個聲明的數組進行混洗。

用法:

tf.util.shuffleCombo (array, array2)

Parameters: 

  • array1:所述第一陣列將被洗牌。它可以是tf.any() [],Uint32Array,Int32Array或Float32Array類型。
  • array2:所述第二陣列將被洗牌。它的類型可以為tf.any() [],Uint32Array,Int32Array或Float32Array。而且,它以與第一個陳述的數組等效的排列進行了混排。

返回值:它返回void。



範例1:

Javascript


// Importing the tensorflow.js library
import * as tf from "@tensorflow/tfjs"
  
// Defining first and second array
const arr = [11, 12, 13, 14, 15];
const arr2 = [16, 17, 18, 19, 20];
  
// Calling tf.util.shuffleCombo() method and
// printing output
tf.util.shuffleCombo(arr, arr2);
console.log(arr, arr2);

輸出:

12,14,11,15,13 17,19,16,20,18

範例2:

Javascript


// Importing the tensorflow.js library
import * as tf from "@tensorflow/tfjs"
  
// Defining first and second array 
// of float values
const arr = [4.5, 6.8, 17.1, 21.23, 45.8];
const arr2 = [47.9, 50.4, 52.5, 62.6, 73.7];
  
// Calling tf.util.shuffleCombo() method and
// printing output
tf.util.shuffleCombo(arr, arr2);
console.log(arr, arr2);

輸出:

17.1,21.23,45.8,4.5,6.8 52.5,62.6,73.7,47.9,50.4

參考:https://js.tensorflow.org/api/latest/#util.shuffleCombo

相關用法


注:本文由純淨天空篩選整理自nidhi1352singh大神的英文原創作品 Tensorflow.js tf.util.shuffleCombo() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。