當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript numjs.array函數代碼示例

本文整理匯總了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'));
    }
  }
}
開發者ID:Islandman93,項目名稱:NeuralNetLog,代碼行數:27,代碼來源:Drawing.ts

示例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);
}
開發者ID:Islandman93,項目名稱:NeuralNetLog,代碼行數:9,代碼來源:Drawing.ts

示例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]]);
開發者ID:minodisk,項目名稱:DefinitelyTyped,代碼行數:25,代碼來源:numjs-tests.ts

示例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]);
開發者ID:IceCreamYou,項目名稱:DefinitelyTyped,代碼行數:23,代碼來源:numjs-tests.ts


注:本文中的numjs.array函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。