Home Reference Source

Function

Static Public Summary
public

arrContains(array: Array, element: undefined): boolean

Check if an element exists in given array or not

public

arrUnique(array: Array): Array

Creates a duplicate-free version of an array

public

assert(condition: boolean, message: undefined)

Check the given condition, if false, throw exception with the given message

public

augment(volume: Vol, crop: number, dx: number, dy: number, flip: number): Vol

Data augmentation to the given volume based on crop.

public
public

getopt(dict: Array, key: undefined, defaultValue: undefined): *

Return the given dict value by key.

public

img_to_vol(img: HTMLImageElement, grayScale: boolean): Vol

Load an HTML DOM image to a virtual canvas and get the pixles data.

public

maxmin(values: undefined): {"maxi": *, "maxv": *, "mini": *, "minv": *, "dv": *}

Return the max/min information of a given value list.

public

Return a random float number between a and b

public

Return a random integer number between a and b

public

randn(mean: number, std: number): number

Return a random number based on the given mean and standard deviation by following Gaussian distribution

public

Generate a incrementing number list between 0 and n, shffle the list and return it as the result

public

range(n: number): *

Return a zero based number list by given size n

public

weightedSample(array: Array, probabilities: Array): *

Return a sample of the given array by given probabilities

public

Return a series of 0

Static Public

public arrContains(array: Array, element: undefined): boolean source

import {arrContains} from 'convnet-sourcecode/src/utils.ts'

Check if an element exists in given array or not

Params:

NameTypeAttributeDescription
array Array
element undefined

Return:

boolean

public arrUnique(array: Array): Array source

import {arrUnique} from 'convnet-sourcecode/src/utils.ts'

Creates a duplicate-free version of an array

Params:

NameTypeAttributeDescription
array Array

Return:

Array

public assert(condition: boolean, message: undefined) source

import {assert} from 'convnet-sourcecode/src/utils.ts'

Check the given condition, if false, throw exception with the given message

Params:

NameTypeAttributeDescription
condition boolean
message undefined

public augment(volume: Vol, crop: number, dx: number, dy: number, flip: number): Vol source

Data augmentation to the given volume based on crop.

  • crop is the size of output
  • dx,dy are offset wrt incoming volume, of the shift
  • flip is boolean on whether we also want to flip the matrix between left and right horizontally

Params:

NameTypeAttributeDescription
volume Vol
crop number
dx number
dy number
flip number

Return:

Vol

public gaussRandom(): number source

import {gaussRandom} from 'convnet-sourcecode/src/utils.ts'

Return a number by following Gaussian distribution by using Box-Muller Transform

Return:

number

public getopt(dict: Array, key: undefined, defaultValue: undefined): * source

import {getopt} from 'convnet-sourcecode/src/utils.ts'

Return the given dict value by key.

  • If key is a string, return the value of dict[key] if exists, otherwise return the defaultValue
  • If key is an array, use the last item of this array as key to query the value in dict

Params:

NameTypeAttributeDescription
dict Array
key undefined
defaultValue undefined

Return:

*

public img_to_vol(img: HTMLImageElement, grayScale: boolean): Vol source

Load an HTML DOM image to a virtual canvas and get the pixles data. Then return a volume based on the image data

  • If grayScale is given, the depth of the volume is 1
  • If grayScale is not given, the depth of the volume is 4 (RGBA)

Params:

NameTypeAttributeDescription
img HTMLImageElement
grayScale boolean

Return:

Vol

public maxmin(values: undefined): {"maxi": *, "maxv": *, "mini": *, "minv": *, "dv": *} source

import {maxmin} from 'convnet-sourcecode/src/utils.ts'

Return the max/min information of a given value list.

Params:

NameTypeAttributeDescription
values undefined

Return:

{"maxi": *, "maxv": *, "mini": *, "minv": *, "dv": *}

public randf(a: number, b: number): number source

import {randf} from 'convnet-sourcecode/src/utils.ts'

Return a random float number between a and b

Params:

NameTypeAttributeDescription
a number
b number

Return:

number

public randi(a: number, b: number): number source

import {randi} from 'convnet-sourcecode/src/utils.ts'

Return a random integer number between a and b

Params:

NameTypeAttributeDescription
a number
b number

Return:

number

public randn(mean: number, std: number): number source

import {randn} from 'convnet-sourcecode/src/utils.ts'

Return a random number based on the given mean and standard deviation by following Gaussian distribution

Params:

NameTypeAttributeDescription
mean number
std number

Return:

number

public randperm(n: number): Array source

import {randperm} from 'convnet-sourcecode/src/utils.ts'

Generate a incrementing number list between 0 and n, shffle the list and return it as the result

Params:

NameTypeAttributeDescription
n number

Return:

Array

public range(n: number): * source

import {range} from 'convnet-sourcecode/src/utils.ts'

Return a zero based number list by given size n

Params:

NameTypeAttributeDescription
n number

Return:

*

public weightedSample(array: Array, probabilities: Array): * source

import {weightedSample} from 'convnet-sourcecode/src/utils.ts'

Return a sample of the given array by given probabilities

Params:

NameTypeAttributeDescription
array Array
probabilities Array

Return:

*

public zeros(n: number): Float64Array source

import {zeros} from 'convnet-sourcecode/src/utils.ts'

Return a series of 0

Params:

NameTypeAttributeDescription
n number

Return:

Float64Array