Skip to content

Instantly share code, notes, and snippets.

View atabakd's full-sized avatar
🏠
Working from home

Atabak Dehban atabakd

🏠
Working from home
View GitHub Profile
@atabakd
atabakd / mps_issues.py
Last active October 12, 2023 23:11
Differing results in cpu/cuda compared to mps
import os
import numpy as np
import torch
from PIL import Image
def gather(consts: torch.Tensor, t: torch.Tensor):
"""Gather consts for $t$ and reshape to feature map shape"""
c = consts.gather(-1, t)
@atabakd
atabakd / kl.py
Last active April 11, 2024 11:31
KL divergence for multivariate samples
# https://mail.python.org/pipermail/scipy-user/2011-May/029521.html
import numpy as np
def KLdivergence(x, y):
"""Compute the Kullback-Leibler divergence between two multivariate samples.
Parameters
----------
x : 2D array (n,d)
@atabakd
atabakd / InvertedPendulum.xml
Last active July 15, 2018 11:37
MJCF description of an inverted pendulum
<mujoco model="inverted pendulum">
<compiler angle="radian"/>
<option timestep="0.001" iterations="20">
<flag sensornoise="enable"/>
</option>
<default>
<geom rgba="0.45 0.6 0.6 1"/>
@atabakd
atabakd / waya-dl-setup.sh
Created November 29, 2017 02:44 — forked from mjdietzx/waya-dl-setup.sh
Install CUDA Toolkit v8.0 and cuDNN v6.0 on Ubuntu 16.04
#!/bin/bash
# install CUDA Toolkit v8.0
# instructions from https://developer.nvidia.com/cuda-downloads (linux -> x86_64 -> Ubuntu -> 16.04 -> deb (network))
CUDA_REPO_PKG="cuda-repo-ubuntu1604_8.0.61-1_amd64.deb"
wget http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/${CUDA_REPO_PKG}
sudo dpkg -i ${CUDA_REPO_PKG}
sudo apt-get update
sudo apt-get -y install cuda
@atabakd
atabakd / confusion_matrix.py
Last active November 12, 2017 17:37
Proper confusion matrix
import numpy as np
from sklearn.metrics import confusion_matrix
from matplotlib import pyplot as plt
import itertools
def plot_confusion_matrix(cm, classes,
normalize=False,
title='Confusion matrix',
cmap=plt.cm.Blues):
"""