neuralee._aux package¶
-
neuralee._aux.
ea
(X, K, neighbors=None)[source]¶ Gaussian entropic affinities.
This computes Gaussian entropic affinities (EAs) for a dataset and a desired perplexity. Reference from:
https://eng.ucmerced.edu/people/vladymyrov/papers/icml13.pdf
Parameters: - X (numpy.ndarray) – sample-coordinates matrix
- K – perplexity.
- neighbors (int) – the number of nearest neighbors
Returns: Gaussian entropic affinities as attractive weights and Euclidean distances as repulsive weights.
-
neuralee._aux.
x2p
(X, perplexity=30.0)[source]¶ Gaussian affinities.
Parameters: - X (numpy.ndarray) – sample-coordinates matrix
- perplexity – perplexity.
Returns: Gaussian affinities as attractive weights and Euclidean distances as repulsive weights.
-
neuralee._aux.
error_ee
(X, Wp, Wn, lam)[source]¶ Elastic embedding loss function.
It’s quite straightforward, may unapplicable when size is large, and the alternative error_ee_cpu and error_ee_cuda are designed to release computation stress.
Parameters: - X (torch.FloatTensor) – sample-coordinates matrix.
- Wp (torch.FloatTensor) – attractive weights.
- Wn (torch.FloatTensor) – repulsive weights.
- lam – trade-off factor of elastic embedding function.
Returns: elastic embedding loss value and the kernel matrix.
-
neuralee._aux.
error_ee_split
(X, Wp, Wn, lam, memory=2, device=None)[source]¶ Elastic embedding loss function deployed on GPU.
It splits X, Wp, Wn into pieces and summarizes respective loss values to release computation stress.
Parameters: - X (torch.FloatTensor) – sample-coordinates matrix
- Wp (torch.FloatTensor) – attractive weights.
- Wn (torch.FloatTensor) – repulsive weights.
- lam – trade-off factor of elastic embedding function.
- memory – memory(GB) allocated to computer error.
- device (torch.device) – device chosen to operate. If None, set as torch.device(‘cpu’).
Returns: elastic embedding loss value.
-
neuralee._aux.
ls_ee
(X, Wp, Wn, lam, P, ff, G, alpha0=1, rho=0.8, c=0.1)[source]¶ Backtracking line search for EE.
Reference:
procedure 3.1, p. 41ff in: Nocedal and Wright: “Numerical Optimization”, Springer, 1999.
Parameters: - X – the current iterate coordinates.
- Wp – attractive weights.
- Wn – repulsive weights.
- lam – trade-off factor of elastic embedding function.
- P – the search direction at current coordinates.
- ff – value of the error function at current coordinates.
- G – gradient of the error function at current coorinates.
- alpha0 – initial step size.
- rho – rate of decrease of the step size.
- c – Wolfe condition.
Returns: new iterate coordinates, new error function value, kernel matrix remained for next iteration and new step size.
-
neuralee._aux.
scatter
(X, labels=None, cell_types=None, title=None, s=1, fg_kwargs={}, size=1.0, lg_kwargs={}, cmap_str='jet')[source]¶ scatter plot.
Parameters: - X (numpy.ndarray) – sample-coordinate matrix.
- labels (numpy.ndarray) – index label. if None, set as np.zeros.
- cell_types (numpy.ndarray) – string for each index label. if None, legend directly displayed as index.
- title – figure title.
- s – point size.
- fg_kwargs (dict) – figure parameters dict. if None, set as {‘dpi’: 200}.
- size (int or percentage) – subsample size of data to show.
- lg_kwargs (dict) – legend parameters dict. if None, set as {‘markerscale’: 2, ‘fontsize’: ‘xx-small’}.
-
neuralee._aux.
scatter_with_colorbar
(X, labels=None, cell_types=None, title=None, s=1, fg_kwargs={}, size=1.0)[source]¶ scatter plot for polarizable situation.
Parameters: - X (numpy.ndarray) – sample-coordinate matrix.
- labels (numpy.ndarray) – index label. if None, set as np.zeros.
- cell_types (numpy.ndarray) – string for each polor, length muse be 2. if None, not show legend.
- title – figure title.
- s – point size.
- fg_kwargs (dict) – figure parameters dict. if None, set as {‘dpi’: 200}.
- size (int or percentage) – subsample size of data to show.