本文整理匯總了TypeScript中numjs.array函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript array函數的具體用法?TypeScript array怎麽用?TypeScript array使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了array函數的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: drawUntiedBias
function drawUntiedBias(node, layer){
// try to get good numbers for a grid
// http://stackoverflow.com/questions/2304052/check-if-a-number-has-a-decimal-place-is-a-whole-number
let gridX = 0, gridY = 0;
let gridXY = Math.sqrt(layer.shape[0]);
// not a whole number
if(gridXY % 1 != 0){
gridX = Math.floor(gridXY);
gridY = Math.ceil(gridXY);
}
else{
gridX = gridXY;
gridY = gridXY;
}
for (let filterInd = 0; filterInd < layer.shape[0]; filterInd++){
let img = normalizeImg(nj.array(layer.values).pick(filterInd));
let canv = document.createElement('canvas');
canv.setAttribute('width', img.shape[0] * 2);
canv.setAttribute('height', img.shape[1] * 2);
canv.getContext("2d").imageSmoothingEnabled = false;
nj.images.save(img, canv);
node.appendChild(canv);
if ((filterInd+1) % gridX == 0) { // +1 because we don't want to br on first (zero indexed)
node.appendChild(document.createElement('br'));
}
}
}
示例2: drawDense
function drawDense(node, layer){
let img = normalizeImg(nj.array(layer.values));
let canv = document.createElement('canvas');
canv.setAttribute('width', img.shape[0]);
canv.setAttribute('height', img.shape[1]);
canv.getContext("2d").imageSmoothingEnabled = false;
nj.images.save(img, canv);
node.appendChild(canv);
}
示例3: abs
import { abs } from 'numjs';
import * as nj from 'numjs';
const a = abs(2);
const arr = nj.arange(6);
arr.reshape(1, 2, 3);
// array([[[ 0, 1, 2],
// [ 3, 4, 5]]])
arr.T;
// array([[[ 0],
// [ 3]],
// [[ 1],
// [ 4]],
// [[ 2],
// [ 5]]])
arr.transpose(1, 0, 2);
// array([[[ 0, 1, 2]],
// [[ 3, 4, 5]]])
const b = nj.array([2, 3, 4]);
const c = nj.uint8([1, 2, 3]);
const d = nj.array<number[]>([[2], [3, 4]]);
示例4: abs
import { abs } from 'numjs';
import * as nj from 'numjs';
const a = abs(2);
const arr = nj.arange(6);
arr.reshape(1, 2, 3);
// array([[[ 0, 1, 2],
// [ 3, 4, 5]]])
arr.T;
// array([[[ 0],
// [ 3]],
// [[ 1],
// [ 4]],
// [[ 2],
// [ 5]]])
arr.transpose(1, 0, 2);
// array([[[ 0, 1, 2]],
// [[ 3, 4, 5]]])
const b = nj.array([2, 3, 4]);
const c = nj.uint8([1, 2, 3]);