Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
Create free account
hub
/
github.com/ddbourgin/numpy-ml
/ functions
Functions
1,202 in github.com/ddbourgin/numpy-ml
⨍
Functions
1,202
◇
Types & classes
166
↓ 62 callers
Function
random_tensor
Create a random real-valued tensor of shape `shape`. If `standardize` is True, ensure each column has mean 0 and std 1.
numpy_ml/utils/testing.py:77
↓ 40 callers
Function
torchify
(var, requires_grad=True)
numpy_ml/tests/nn_torch_models.py:17
↓ 30 callers
Method
backward
(self, out, **kwargs)
numpy_ml/neural_nets/modules/modules.py:37
↓ 26 callers
Method
grad
Compute the gradient of the VLB with regard to the network parameters. Parameters ---------- y : :py:class:`ndarray
numpy_ml/neural_nets/losses/losses.py:296
↓ 25 callers
Method
backward
(grad_output)
numpy_ml/tests/nn_torch_models.py:134
↓ 24 callers
Function
err_fmt
(params, golds, ix, warn_str="")
numpy_ml/tests/test_nn.py:64
↓ 23 callers
Method
act_fn
The activation function for the base layer.
numpy_ml/neural_nets/wrappers/wrappers.py:73
↓ 22 callers
Method
forward
(self, z, **kwargs)
numpy_ml/neural_nets/modules/modules.py:33
↓ 21 callers
Method
__init__
A Restricted Boltzmann machine with Bernoulli visible and hidden units. Parameters ---------- n_out : int
numpy_ml/neural_nets/layers/layers.py:366
↓ 21 callers
Method
__init__
(self)
numpy_ml/tests/nn_torch_models.py:52
↓ 19 callers
Method
predict
Use the trained decision tree to classify or predict the examples in `X`. Parameters ---------- X : :py:class:`ndarr
numpy_ml/trees/dt.py:87
↓ 16 callers
Method
fit
Fit a binary decision tree to a dataset. Parameters ---------- X : :py:class:`ndarray <numpy.ndarray>` of shape `(N,
numpy_ml/trees/dt.py:70
↓ 15 callers
Function
loss
(yp, y)
numpy_ml/tests/test_trees.py:88
↓ 13 callers
Function
pad2D
Zero-pad a 4D input volume `X` along the second and third dimensions. Parameters ---------- X : :py:class:`ndarray <numpy.ndarray>`
numpy_ml/neural_nets/utils/utils.py:252
↓ 12 callers
Method
__init__
r""" An exponential linear unit (ELU). Notes ----- ELUs are intended to address the fact that ReLUs are strictly nonn
numpy_ml/neural_nets/activations/activations.py:413
↓ 12 callers
Method
copy
Return a copy of the current object.
numpy_ml/neural_nets/schedulers/schedulers.py:27
↓ 12 callers
Function
logsumexp
Redefine scipy.special.logsumexp see: http://bayesjumping.net/log-sum-exp-trick/
numpy_ml/utils/misc.py:5
↓ 11 callers
Method
reset
Reset the bandit step and action counters to zero.
numpy_ml/bandits/bandits.py:69
↓ 10 callers
Method
gradients
Return a dictionary of the gradients computed during the backward pass
numpy_ml/neural_nets/layers/layers.py:4201
↓ 10 callers
Method
predict
r""" Generate predictions for the targets associated with the rows in `X`. Parameters ---------- X : numpy array of s
numpy_ml/nonparametric/knn.py:62
↓ 10 callers
Method
predict
Use the trained model to generate predictions on a new collection of data points. Parameters ---------- X :
numpy_ml/linear_models/linear_regression.py:218
↓ 10 callers
Method
train
Train the LDA model on a corpus of documents (bags of words). Parameters ---------- corpus : list of length `D`
numpy_ml/lda/lda.py:206
↓ 9 callers
Function
random_stochastic_matrix
Create a random stochastic matrix of shape (`n_examples`, `n_classes`)
numpy_ml/utils/testing.py:70
↓ 9 callers
Method
step
Increment the optimizer step counter by 1
numpy_ml/neural_nets/optimizers/optimizers.py:25
↓ 8 callers
Method
fn
r""" Evaluate the ELU activation on the elements of input `z`. .. math:: \text{ELU}(z_i) &= z_i \ \ \ \
numpy_ml/neural_nets/activations/activations.py:449
↓ 8 callers
Function
torch_gradient_generator
(fn, **kwargs)
numpy_ml/tests/test_nn_activations.py:14
↓ 7 callers
Method
fit
r""" Fit regression coefficients via maximum likelihood. Parameters ---------- X : :py:class:`ndarray <numpy.ndarray>
numpy_ml/linear_models/linear_regression.py:172
↓ 7 callers
Method
flush_gradients
Erase all the layer's derived variables and gradients.
numpy_ml/neural_nets/layers/layers.py:4244
↓ 7 callers
Function
is_number
Check that a value `a` is numeric
numpy_ml/utils/testing.py:38
↓ 7 callers
Method
pop
Remove the item with the largest/smallest (depending on ``self.heap_order``) priority from the queue and return it. Notes
numpy_ml/utils/data_structures.py:127
↓ 6 callers
Function
ReLULayer
(name, n_in, n_out, inputs, w_initialization)
numpy_ml/tests/nn_torch_models.py:1846
↓ 6 callers
Method
__init__
(self, rewards, reward_probs, context=None)
numpy_ml/bandits/bandits.py:11
↓ 6 callers
Function
calc_pad_dims_2D
Compute the padding necessary to ensure that convolving `X` with a 2D kernel of shape `kernel_shape` and stride `stride` produces outputs wit
numpy_ml/neural_nets/utils/utils.py:51
↓ 6 callers
Method
encode
Encode a collection of multi-featured examples into a `n_dim`-dimensional feature matrix via feature hashing. Notes
numpy_ml/preprocessing/general.py:301
↓ 6 callers
Method
fit
r""" Fit the model to the data and targets in `X` and `y` Parameters ---------- X : numpy array of shape `(N, M)`
numpy_ml/nonparametric/knn.py:47
↓ 6 callers
Function
pad1D
Zero-pad a 3D input volume `X` along the second dimension. Parameters ---------- X : :py:class:`ndarray <numpy.ndarray>` of shape `(
numpy_ml/neural_nets/utils/utils.py:195
↓ 6 callers
Function
torch_gradient_generator
(fn, **kwargs)
numpy_ml/tests/nn_torch_models.py:21
↓ 6 callers
Method
update
r""" Update the agent parameters according to the rewards accrued on the current episode. Returns ------- avg
numpy_ml/rl_models/agents.py:87
↓ 5 callers
Method
__init__
The variational lower bound for a variational autoencoder with Bernoulli units. Notes ----- The VLB to the s
numpy_ml/neural_nets/losses/losses.py:226
↓ 5 callers
Method
flush_history
Clear the episode history
numpy_ml/rl_models/agents.py:40
↓ 5 callers
Method
forward
Perform the CD-`k` "forward pass" of visible inputs into hidden units and back. Notes ----- This implementat
numpy_ml/neural_nets/layers/layers.py:468
↓ 5 callers
Method
forward
(self, X)
numpy_ml/tests/nn_torch_models.py:1477
↓ 5 callers
Method
get_neighbors
Return the internal indices of the vertices reachable from the vertex with index `v_i`.
numpy_ml/utils/graphs.py:83
↓ 5 callers
Function
tokenize_words
Split a string into individual words, optionally removing punctuation and stop-words in the process.
numpy_ml/preprocessing/nlp.py:77
↓ 5 callers
Method
update
Update the layer parameters using the accrued gradients and layer optimizer. Flush all gradients once the update is complete.
numpy_ml/neural_nets/layers/layers.py:4248
↓ 4 callers
Method
__init__
(self)
numpy_ml/neural_nets/modules/modules.py:22
↓ 4 callers
Method
__init__
Abstract base class for all Scheduler objects.
numpy_ml/neural_nets/schedulers/schedulers.py:20
↓ 4 callers
Method
__init__
(self, env)
numpy_ml/rl_models/agents.py:13
↓ 4 callers
Method
__init__
r""" A UCB1 policy for multi-armed bandit problems. Notes ----- The UCB1 algorithm [*]_ guarantees the cumulative reg
numpy_ml/bandits/policies.py:188
↓ 4 callers
Method
_create_2num_dicts
(self, obs_encoder=None, act_encoder=None)
numpy_ml/rl_models/agents.py:21
↓ 4 callers
Method
backward
Perform a gradient update on the layer parameters via the contrastive divergence equations. Parameters ----------
numpy_ml/neural_nets/layers/layers.py:563
↓ 4 callers
Function
calc_fan
Compute the fan-in and fan-out for a weight matrix/volume. Parameters ---------- weight_shape : tuple The dimensions of the
numpy_ml/neural_nets/utils/utils.py:352
↓ 4 callers
Function
conv2D
A faster (but more memory intensive) implementation of the 2D "convolution" (technically, cross-correlation) of input `X` with a collection o
numpy_ml/neural_nets/utils/utils.py:603
↓ 4 callers
Function
dg
E[log X_t] where X_t ~ Dir
numpy_ml/lda/lda.py:255
↓ 4 callers
Method
filter
Filter (or replace) any word in `words` that is not present in `Vocabulary`. Parameters ---------- words : l
numpy_ml/preprocessing/nlp.py:1105
↓ 4 callers
Method
fn
r""" Evaluate the logistic sigmoid, :math:`\sigma`, on the elements of input `z`. .. math:: \sigma(x_i) = \frac{1}{1 + e
numpy_ml/neural_nets/activations/activations.py:39
↓ 4 callers
Method
forward
Perform the forward pass for either the generator or the critic. Parameters ---------- X : :py:class:`ndarray <numpy
numpy_ml/neural_nets/models/wgan_gp.py:206
↓ 4 callers
Function
im2col
Pads and rearrange overlapping windows of the input volume into column vectors, returning the concatenated padded vectors in a matrix `X_col`
numpy_ml/neural_nets/utils/utils.py:486
↓ 4 callers
Method
log_prob
r""" Compute the smoothed log probability of a sequence of words under the `N`-gram language model with additive smoothing. N
numpy_ml/ngram/ngram.py:402
↓ 4 callers
Method
loss
Variational lower bound for a Bernoulli VAE. Parameters ---------- y : :py:class:`ndarray <numpy.ndarray>` of shape
numpy_ml/neural_nets/losses/losses.py:261
↓ 4 callers
Function
ngrams
Return all `N`-grams of the elements in `sequence`
numpy_ml/preprocessing/nlp.py:58
↓ 4 callers
Function
param
A wrapper for `tf.Variable` which enables parameter sharing in models. Creates and returns theano shared variables similarly to `tf.Variable
numpy_ml/tests/nn_torch_models.py:1816
↓ 4 callers
Method
predict
Return the MAP estimate for :math:`y^*`, corresponding the mean/mode of the posterior predictive distribution, :math:`p(y^* \mid x^*,
numpy_ml/nonparametric/gp.py:64
↓ 4 callers
Method
predict
Generate predictions for the targets associated with the rows in `X`. Parameters ---------- X : :py:class:`ndarray <
numpy_ml/nonparametric/kernel_regression.py:53
↓ 4 callers
Method
predict
Return the MAP prediction for the targets associated with `X`. Parameters ---------- X : :py:class:`ndarray <numpy.n
numpy_ml/linear_models/bayesian_regression.py:139
↓ 4 callers
Method
predict
Return the MAP prediction for the targets associated with `X`. Parameters ---------- X : :py:class:`ndarray <numpy.n
numpy_ml/linear_models/bayesian_regression.py:276
↓ 4 callers
Method
predict
Predict the target value for each entry in `X`. Parameters ---------- X : :py:class:`ndarray <numpy.ndarray>` of sha
numpy_ml/trees/rf.py:61
↓ 4 callers
Method
predict
Use the trained model to classify or predict the examples in `X`. Parameters ---------- X : :py:class:`ndarray <nump
numpy_ml/trees/gbdt.py:158
↓ 4 callers
Function
random_one_hot_matrix
Create a random one-hot matrix of shape (`n_examples`, `n_classes`)
numpy_ml/utils/testing.py:63
↓ 4 callers
Function
random_paragraph
Generate a random paragraph consisting of `n_words` words. If `vocab` is not None, words will be drawn at random from this list. Otherwise, w
numpy_ml/utils/testing.py:99
↓ 4 callers
Function
random_unweighted_graph
Generate an unweighted Erdős-Rényi random graph [*]_. References ---------- .. [*] Erdős, P. and Rényi, A. (1959). On Random Graphs,
numpy_ml/utils/graphs.py:302
↓ 4 callers
Method
sample
Sample functions from the GP prior or posterior predictive distribution. Parameters ---------- X : :py:class
numpy_ml/nonparametric/gp.py:223
↓ 4 callers
Function
to_networkx
Convert my graph representation to a networkx graph
numpy_ml/tests/test_utils.py:241
↓ 4 callers
Method
train
Train an agent on an OpenAI gym environment, logging training statistics along the way. Parameters ----------
numpy_ml/rl_models/trainer.py:33
↓ 4 callers
Method
update
(self, cur_loss=None)
numpy_ml/neural_nets/modules/modules.py:58
↓ 4 callers
Method
update
Perform gradient updates and flush gradients upon completion
numpy_ml/neural_nets/models/wgan_gp.py:436
↓ 3 callers
Function
Discriminator
(inputs, params=None)
numpy_ml/tests/nn_torch_models.py:1901
↓ 3 callers
Method
__init__
A stochastic gradient descent optimizer. Notes ----- For model parameters :math:`\\theta`, averaged parameter gradie
numpy_ml/neural_nets/optimizers/optimizers.py:59
↓ 3 callers
Method
__init__
Radial basis function (RBF) / squared exponential kernel. Notes ----- For input vectors :math:`\mathbf{x}` and :math
numpy_ml/utils/kernels.py:185
↓ 3 callers
Method
__init__
A simple, unsmoothed N-gram model. Parameters ---------- N : int The maximum length (in words) of the co
numpy_ml/ngram/ngram.py:314
↓ 3 callers
Method
_log_prob
Calculate the log probability of a sequence of words under the `N`-gram model
numpy_ml/ngram/ngram.py:255
↓ 3 callers
Method
_traverse
(self, X, node, prob=False)
numpy_ml/trees/dt.py:205
↓ 3 callers
Method
backward
Perform the backward pass for either the generator or the critic. Parameters ---------- grad : :py:class:`ndarray <n
numpy_ml/neural_nets/models/wgan_gp.py:246
↓ 3 callers
Function
col2im
Take columns of a 2D matrix and rearrange them into the blocks/windows of a 4D image volume. Notes ----- A NumPy reimagining of
numpy_ml/neural_nets/utils/utils.py:546
↓ 3 callers
Method
fit
Fit the GP prior to the training data. Parameters ---------- X : :py:class:`ndarray <numpy.ndarray>` of shape `(N, M
numpy_ml/nonparametric/gp.py:44
↓ 3 callers
Method
fit
Fit the regression model to the data and targets in `X` and `y`. Parameters ---------- X : :py:class:`ndarray <numpy
numpy_ml/nonparametric/kernel_regression.py:40
↓ 3 callers
Method
fit
Compute the vocabulary across a collection of documents. Parameters ---------- corpus_fps : str or list of strs
numpy_ml/preprocessing/nlp.py:1166
↓ 3 callers
Method
flush_gradients
Reset parameter gradients to 0 after an update.
numpy_ml/neural_nets/models/wgan_gp.py:424
↓ 3 callers
Method
fn
r""" Compute the GELU function on the elements of input `z`. .. math:: \text{GELU}(z_i) = z_i P(Z \leq z_i) = z_i \Phi(z
numpy_ml/neural_nets/activations/activations.py:239
↓ 3 callers
Method
forward
Compute the layer output on a single minibatch. Parameters ---------- X : :py:class:`ndarray <numpy.ndarray>` of sha
numpy_ml/neural_nets/layers/layers.py:2263
↓ 3 callers
Function
generalized_cosine
The generalized cosine family of window functions. Notes ----- The generalized cosine window is a simple weighted sum of cosine term
numpy_ml/utils/windows.py:108
↓ 3 callers
Method
grad
r""" Evaluate the first derivative of the GELU function on the elements of input `x`. .. math:: \frac{\partial \
numpy_ml/neural_nets/activations/activations.py:254
↓ 3 callers
Method
grad2
r""" Evaluate the second derivative of the ELU activation on the elements of input `x`. .. math:: \frac{\partial
numpy_ml/neural_nets/activations/activations.py:476
↓ 3 callers
Function
kernel_checks
(X, Y)
numpy_ml/utils/kernels.py:299
↓ 3 callers
Function
log_gaussian_pdf
Compute log N(x_i | mu, sigma)
numpy_ml/utils/misc.py:16
↓ 3 callers
Method
log_likelihood
r""" Given the HMM parameterized by :math:`(A`, B, \pi)` and an observation sequence `O`, compute the marginal likelihood of `O`,
numpy_ml/hmm/hmm.py:122
↓ 3 callers
Method
log_prob
Compute the log probability of a sequence of words under the unsmoothed, maximum-likelihood `N`-gram language model. Paramet
numpy_ml/ngram/ngram.py:335
↓ 3 callers
Method
log_prob
r""" Compute the smoothed log probability of a sequence of words under the `N`-gram language model with Good-Turing smoothing.
numpy_ml/ngram/ngram.py:512
↓ 3 callers
Function
loss
(yp, y)
numpy_ml/plots/trees_plots.py:39
↓ 3 callers
Method
loss
Compute the squared error between `y` and `y_pred`. Parameters ---------- y : :py:class:`ndarray <numpy.ndarray>` of
numpy_ml/neural_nets/losses/losses.py:49
next →
1–100 of 1,202, ranked by callers