Miscellaneous functionality¶
Module holding miscellaneous functionality.
-
breze.arch.component.misc.
pairwise_diff
(X, Y=None)¶ Given two arrays with samples in the row, compute the pairwise differences.
Parameters: X : Theano variable
Has shape
(n, d)
. Contains one item per first dimension.Y : Theano variable, optional [default: None]
Has shape
(m, d)
. If not given, defaults toX
.Returns: res : Theano variable
Has shape
(n, d, m)
.
-
breze.arch.component.misc.
distance_matrix
(X, Y=None, norm=<function l2>)¶ Return an expression containing the distances given the norm of up to two arrays containing samples.
Parameters: X : Theano variable
Has shape
(n, d)
. Contains one item per first dimension.Y : Theano variable, optional [default: None]
Has shape
(m, d)
. If not given, defaults toX
.norm : string or callable
Either a string pointing at a function in
breze.arch.component.norm
or a function that has the same signature as these.Returns: res : Theano variable
Has shape
(n, m)
.
-
breze.arch.component.misc.
distance_matrix_by_diff
(diff, norm=<function l2>)¶ Return an expression containing the distances given the norm
norm
arrays containing samples.Parameters: D : Theano variable
Has shape
(n, d, m)
and represents differences between two collections of the same set.norm : string or callable
Either a string pointing at a function in
breze.arch.component.norm
or a function that has the same signature as these.Returns: res : Theano variable
Has shape
(n, m)
.
-
breze.arch.component.misc.
cat_entropy
(arr)¶ Return the entropy of categorical distributions described by the rows in
arr
.Parameters: arr : Theano variable
Array of shape
(n, d)
describingn
different categorical variables. Rows need to sum up to1
and be non-negative.Returns: res : theano variable
Has shape
(n,)
.
-
breze.arch.component.misc.
project_into_l2_ball
(arr, radius=1)¶ Return
arr
projected into the L2 ball.Parameters: arr : Theano variable
Array of shape either
(n, d)
or(d,)
. If the former, all rows are projected individually.radius : float, optional [default: 1]
Returns: res : Theano variable
Projected result of the same shape as
arr
.