Skip to content

Instantly share code, notes, and snippets.

View tdavchev's full-sized avatar
🤞
researching

Todor Davchev tdavchev

🤞
researching
View GitHub Profile
for t in range(T):
exp_feat += gamma**t * (trajectory[t, :] - goal)**2
@tdavchev
tdavchev / qp_opt.py
Created January 9, 2021 13:59
QP Optimiser
class QPoptimizer(object):
def __call__(self, feature_num, learner, expert):
w = cp.Variable(feature_num)
obj_func = cp.Minimize(cp.norm(w))
constraints = [(expert-learner) @ w >= 2]
prob = cp.Problem(obj_func, constraints)
prob.solve()
'''
Convert videos to .gif files.
@date: 28.02.2018
@author: Todor Davchev
'''
import argparse
import os
import numpy as np
import seaborn as sns
import matplotlib.pyplot as plt
def smooth(scalars, weight):
last = scalars[0]
smoothed = list()
for point in scalars:
smoothed_val = last * weight + (1-weight)*point
@tdavchev
tdavchev / explore.py
Last active April 16, 2020 21:23
A simple implementation of OU exploration noise.
import numpy as np
# Taken from https://github.com/openai/baselines/blob/master/baselines/ddpg/noise.py
# based on http://math.stackexchange.com/questions/1287634/implementing-ornstein-uhlenbeck-in-matlab
class OrnsteinUhlenbeckActionNoise(object):
def __init__(self, mu, sigma=0.3, theta=.15, dt=1e-2, x_0=None):
self.theta = theta
self.mu = mu
self.sigma = sigma
self.dt = dt
@tdavchev
tdavchev / [fix] VLX issues STEAM
Last active December 20, 2019 21:28
glXChooseVisual failedMain.cpp (332) : Assertion Failed: Fatal Error: glXChooseVisual failed
sudo rm /usr/lib/i386-linux-gnu/mesa/libGL.so.1
def get_model_params(self):
# get trainable params.
model_names = []
model_params = []
model_shapes = []
with self.g.as_default():
t_vars = tf.trainable_variables()
for var in t_vars:
param_name = var.name
p = self.sess.run(var)
import pickle
import numpy as np
def social_frame_preprocess():
'''
Preprocess the frames from the datasets.
Convert values to pixel locations from millimeters
obtain and store all frames data the actually used frames (as some are skipped),
the ids of all pedestrians that are present at each of those frames and the sufficient statistics.
'''
@tdavchev
tdavchev / Markov Random Field Image de-noising
Created November 21, 2016 23:13
Simple Python implementation of the Markov Random Field (MRF) Image de-noising illustration from Bishop's Pattern Recognition and Machine Learning Book, Chapter 8
from scipy import misc
import numpy as np
import random
from pylab import *
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
import matplotlib.pyplot as plt
im = misc.imread('lena512.bmp')
im = np.asarray(im)
" This must be first, because it changes other options as side effect
set nocompatible
" Use pathogen to easily modify the runtime path to include all
" plugins under the ~/.vim/bundle directory
call pathogen#helptags()
call pathogen#infect()
" Quickly edit/reload the vimrc file
" nmap <silent> <leader>ev :e $MYVIMRC<CR>