Tensorflow.js是一個開放源代碼庫,由Google開發,用於在瀏覽器或節點環境中運行機器學習模型以及深度學習神經網絡。
.real()函數用於查找指定張量輸入的張量,該張量為float類型,是輸入中被視為複數的每個元素的實數部分。
用法:
tf.real( input )
參數:
- input:它是張量輸入,它使用一個複數作為輸入。
返回值:它返回複數或實數張量輸入的實數部分。
範例1:在此示例中,我們定義了一個float類型的輸入張量,然後打印它的實部。為了創建輸入張量,我們使用.complex()方法,並且為了打印輸出,我們使用.print()方法。
Javascript
// Defining input tensor
const y = tf.complex([-9.25, 12.25], [6.66, 8.66]);
// Calling real() function and
// printing the output
tf.real(y).print();
輸出:
Tensor [-9.25, 12.25]
範例2:在此示例中,我們使用null,character和整數類型值作為張量輸入。
Javascript
// Defining input tensor
const y = tf.complex([null, 'a'], [5, 'r']);
// Calling real() function
var z = tf.real(y);
// Prints output
z.print();
輸出:
Tensor [0, NaN]
在上麵的示例中,空值返回零,字符類型值返回NaN。
相關用法
- 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()用法及代碼示例
注:本文由純淨天空篩選整理自nidhi1352singh大神的英文原創作品 Tensorflow.js tf.real() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。