Buckets:
utils/maths
Numerical helpers — softmax, dot product, cosine similarity, and the typed-array utilities shared across the library.
Functions
softmax(arr)
Compute the softmax of an array of numbers.
Parameters
arr(TypedArray|number[]) — The array of numbers to compute the softmax of.
Returns: TypedArray | number[] — The softmax array.
log_softmax(arr)
Calculates the logarithm of the softmax function for the input array.
Parameters
arr(TypedArray|number[]) — The input array to calculate the log_softmax function for.
Returns: TypedArray | number[] — The resulting log_softmax array.
dot(arr1, arr2)
Calculates the dot product of two arrays.
Parameters
arr1(number[]) — The first array.arr2(number[]) — The second array.
Returns: number — The dot product of arr1 and arr2.
cos_sim(arr1, arr2)
Computes the cosine similarity between two arrays.
Parameters
arr1(number[]) — The first array.arr2(number[]) — The second array.
Returns: number — The cosine similarity between the two arrays.
Type Definitions
TypedArray
Type: Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float16Array | Float32Array | Float64Array
BigTypedArray
Type: BigInt64Array | BigUint64Array
AnyTypedArray
Type: TypedArray | BigTypedArray
Xet Storage Details
- Size:
- 1.74 kB
- Xet hash:
- e89dc75d47349dca233296ca7d93249bb7e280105ab58d0999822c521d426352
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.