Skip to content

Instantly share code, notes, and snippets.

Avatar
💻

Krishnan Srinivasan krishpop

💻
View GitHub Profile
@krishpop
krishpop / spinup_run_script.py
Created Jun 28, 2019
Minimal example of Spinup Experiment (DDPG)
View spinup_run_script.py
from spinup.utils.run_utils import ExperimentGrid
from spinup import ddpg
import gym
import tensorflow as tf
def run_experiment(args):
def env_fn():
import envs # registers custom envs to gym env registry
return gym.make(args.env_name)
@krishpop
krishpop / similarity.py
Created Apr 16, 2019
Similarity metrics for Sparse Matrices
View similarity.py
def jaccard_metric(x, y):
"""
x: scipy.sparse CSR matrix shape (1, n)
y: scipy.sparse CSR matrix shape (1, n)
returns: jaccard similarity
"""
return x.minimum(y).sum()/x.maximum(y).sum()
def l2_metric(x,y):
"""
@krishpop
krishpop / rl-packages.md
Last active Oct 4, 2020
RL Packages and Implementations
View rl-packages.md
View init.coffee
# Your init script
#
# Atom will evaluate this file each time a new window is opened. It is run
# after packages are loaded/activated and after the previous editor state
# has been restored.
#
# An example hack to log to the console when each text editor is saved.
#
# atom.workspace.observeTextEditors (editor) ->
# editor.onDidSave ->
View Tensorflow Tutorial.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@krishpop
krishpop / dataset.py
Last active Aug 8, 2017
Tensorflow dataset class
View dataset.py
# Code adapted from TensorFlow source example:
# https://github.com/tensorflow/tensorflow/blob/master/tensorflow/contrib/learn/python/learn/datasets/mnist.py
class DataSet:
"""Base data set class
"""
def __init__(self, shuffle=True, labeled=True, **data_dict):
assert '_data' in data_dict
if labeled:
View export-toby.js
// code courtesy of Toby team
chrome.storage.local.get("state", o => (
((f, t) => {
let e = document.createElement("a");
e.setAttribute("href", `data:text/plain;charset=utf-8,${encodeURIComponent(t)}`);
e.setAttribute("download", f);
e.click();
})(`TobyBackup${Date.now()}.json`, o.state)
));
View cA.py
"""This tutorial introduces Contractive auto-encoders (cA) using Theano.
They are based on auto-encoders as the ones used in Bengio et
al. 2007. An autoencoder takes an input x and first maps it to a
hidden representation y = f_{\theta}(x) = s(Wx+b), parameterized by
\theta={W,b}. The resulting latent representation y is then mapped
back to a "reconstructed" vector z \in [0,1]^d in input space z =
g_{\theta'}(y) = s(W'y + b'). The weight matrix W' can optionally be
constrained such that W' = W^T, in which case the autoencoder is said
to have tied weights. The network is trained such that to minimize
View BashPS1.md
Shortcut Meaning
\a an ASCII bell character (07)
\d the date in “Weekday Month Date” format (e.g., “Tue May 26”)
\D{format} the format is passed to strftime(3) and the result is inserted into the prompt string; an empty format results in a locale-specific time representation. The braces are requir
View RandomForestRegressor.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.