本文整理汇总了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]);