Tensorflow.js是Google開發的開源庫,用於在瀏覽器或節點環境中運行機器學習模型和深度學習神經網絡。
tf.transpose()函數用於在指定的二維輸入張量上執行常規矩陣轉置操作。
用法:
tf.transpose (x)
參數:此函數接受如下所示的參數:
- x:要轉置的指定輸入張量。
返回值:它返回張量作為轉置操作的輸出。
範例1:
Javascript
// Importing the tensorflow.js library
import * as tf from "@tensorflow/tfjs"
// Initializing a tensor of matrix along with
// its dimension
const a = tf.tensor2d([2, 4, 6, 8], [2, 2]);
// Calling the .transpose() function over the
// above tensor as its parameter
a.transpose().print();
輸出:
Tensor [[2, 6], [4, 8]]
範例2:
Javascript
// Importing the tensorflow.js library
import * as tf from "@tensorflow/tfjs"
// Using some tensor of matrix along with its dimensions
// as the parameter for .transpose() functions
tf.tensor2d([1, 3, 5, 7, 9, 11], [2, 3]).transpose().print();
tf.tensor2d([1, 3, 5, 7, 9, 11], [3, 2]).transpose().print();
輸出:
Tensor [[1, 7 ], [3, 9 ], [5, 11]] Tensor [[1, 5, 9 ], [3, 7, 11]]
相關用法
- PHP imagecreatetruecolor()用法及代碼示例
- p5.js year()用法及代碼示例
- d3.js d3.utcTuesdays()用法及代碼示例
- PHP ImagickDraw getTextAlignment()用法及代碼示例
- PHP Ds\Sequence last()用法及代碼示例
- PHP Imagick floodFillPaintImage()用法及代碼示例
- PHP array_udiff_uassoc()用法及代碼示例
- PHP geoip_continent_code_by_name()用法及代碼示例
- d3.js d3.map.set()用法及代碼示例
- PHP GmagickPixel setcolor()用法及代碼示例
- PHP opendir()用法及代碼示例
- PHP cal_to_jd()用法及代碼示例
- d3.js d3.bisectLeft()用法及代碼示例
- PHP stream_get_transports()用法及代碼示例
- PHP Ds\Deque pop()用法及代碼示例
注:本文由純淨天空篩選整理自Kanchan_Ray大神的英文原創作品 Tensorflow.js tf.transpose() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。