Skip to content

Instantly share code, notes, and snippets.

Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ragulpr
ragulpr / pytorch-memtest.py
Last active November 1, 2018 22:46
memory mechanics in pytorch. Override variable names or make new?
import torch
@profile
def keep():
x = torch.randn(10000,100)
y = x+1
z = y**2
w = z**2
return w
# keep()
@ragulpr
ragulpr / gumbel_softmax.ipynb
Last active November 1, 2018 06:22
(Most) Minimal example testing different implementations of torch.nn.gumbel_softmax for pull #13339
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ragulpr
ragulpr / rnntest.py
Last active May 11, 2018 07:27
pytorch dataparallell unexpected behaviour
import numpy as np
import matplotlib
matplotlib.use('agg')
import matplotlib.pyplot as plt
import torch
import torch.nn as nn
import torch.nn.functional as F
print('torch.__version__',torch.__version__)
@ragulpr
ragulpr / gitlogs_to_csv.sh
Created April 27, 2018 05:42
Exports all git logs in tree as csv
#!/bin/bash
# Go to a git-repository and neatly export the commit log.
# assumes "_Z_Z_Z_" and "_Y_Y_" "_X_X_" as unused characters
# (just some improbable string i wrote)
# Truncate subject line sanitized (%f) or not (%s) to 79 %<(79,trunc)%f
for repo in $(ls -d */) ; do
echo $repo
cd $repo
inside_git_repo="$(git rev-parse --is-inside-work-tree 2>/dev/null)"
We can't make this file beautiful and searchable because it's too large.
commit,author_name,time_sec,subject,files_changed,lines_inserted,lines_deleted
8a428cdd35,"ekelsen",1524782988,"Merge-pull-request-18846-from-yongtang-04252018-FloorDiv-int8 ",,,
ce733dc348,"ekelsen",1524781964,"Merge-pull-request-18881-from-ManHyuk-fix_typo ",,,
5cd6a8d1ed,"ekelsen",1524781835,"Merge-pull-request-18907-from-yongtang-18363-mpi ",,,
d0b961306a,"ekelsen",1524781628,"Merge-pull-request-18896-from-KikaTech-fix_lite_topk ",,,
1bf9ec7f85,"Yong Tang",1524775671,"Fix-cmake-build-issues-with-GPU-on-Linux-18775 ",4,17,1
4bd6ac7ce0,"Martin Wicke",1524775556,"Merge-pull-request-17602-from-joeyearsley-patch-1 ",,,
26b2814096,"Yong Tang",1524774078,"Fix-build-error-with-MPI-support ",1,1,
3e51dbba08,"Yifei Feng",1524767245,"Merge-pull-request-18885-from-drpngx-branch_194337205
@ragulpr
ragulpr / py
Last active March 20, 2017 22:13
Keras masking layer performance
import keras
from keras.layers import *
from keras.models import Model
import theano as T
import tensorflow as tf
print('theano ver.',T.__version__)
print('tensorflow ver.',tf.__version__)
print('keras ver.',keras.__version__)
np.set_printoptions(precision=4)
np.random.seed(1)
@ragulpr
ragulpr / py
Last active December 7, 2020 10:24
Keras masking example
import keras
from keras.layers import *
from keras.models import Model
import theano as T
import tensorflow as tf
print('theano ver.',T.__version__)
print('tensorflow ver.',tf.__version__)
print('keras ver.',keras.__version__)
np.set_printoptions(precision=4)
np.random.seed(1)
def load_challenge_data(df,start_at,truncate_at):
seq_len = np.max([truncate_at,df[:,1].max().astype(int)+1])
n_vars = df.shape[1]-2 # Drop unit_number and time
n_series = int(df[:,0].max())
feature_data = np.zeros([seq_len,n_series,n_vars])
times_to_event = np.zeros([seq_len,n_series,1])
seq_lengths = np.zeros([n_series])
mask = np.ones([seq_len,n_series,1])