Skip to content

Instantly share code, notes, and snippets.

View smoussa's full-sized avatar
🚀

Samir Moussa smoussa

🚀
View GitHub Profile
@mbsariyildiz
mbsariyildiz / .py
Last active March 8, 2024 20:44
Pairwise Euclidean distance computation of elements in 2 tensors, in TensorFlow.
def pairwise_dist (A, B):
"""
Computes pairwise distances between each elements of A and each elements of B.
Args:
A, [m,d] matrix
B, [n,d] matrix
Returns:
D, [m,n] matrix of pairwise distances
@karpathy
karpathy / nes.py
Last active June 28, 2024 12:59
Natural Evolution Strategies (NES) toy example that optimizes a quadratic function
"""
A bare bones examples of optimizing a black-box function (f) using
Natural Evolution Strategies (NES), where the parameter distribution is a
gaussian of fixed standard deviation.
"""
import numpy as np
np.random.seed(0)
# the function we want to optimize