Skip to content

Instantly share code, notes, and snippets.

View yrevar's full-sized avatar

yrevar

View GitHub Profile
import numpy
import pylab
from pylab import *
from matplotlib.widgets import Slider, Button, RadioButtons
# default 2d transformation matrix values
x1_def, x2_def, y1_def, y2_def = 1,0,0,1
ax = subplot(111)
subplots_adjust(bottom=0.25)
# -*- coding: utf-8 -*-
import numpy as np
import pylab
"""
Imagine you have two random variables X_1 and X_2 and both of them are normally distributed, but with different parameters. In this example, let's say distribution of X_1 is g1(x) and for X2 it is g2(x).
P(X_1) ~ N(µ1,Σ1), P(X_2) ~ N(µ2, Σ2). Where Σ1 and Σ2 are variances of X_1 and X_2 consecutively which are in this example s1^2 and s2^2.
@yrevar
yrevar / bashrc backup gist
Created March 17, 2016 19:51
Backup your bashrc on gist with a very simple command. It preserves the gist url and updates the same file you backed up on gist before.
# Target OS: Linux/Mac
# Prerequisites: Make sure you have installed and setup gist (https://github.com/defunkt/gist), and modified bashrc path as per your own setup which in my case was $HOME/.bash_profile.
gist -u $(cat $HOME/.bashrc_gisturl) -c -p -f "my_last_bashrc" -d "`date`" $HOME/.bash_profile > $HOME/.bashrc_gisturl
export PATH=$PATH:/$HOME/bin
if [ -z ${DISPLAY} ]
then
export DISPLAY=:0.0
fi
# Terminal history settings
export HISTCONTROL=ignoredups:erasedups # no duplicate entries
export HISTSIZE=1000000 # big big history
export HISTFILESIZE=1000000 # big big history
name: "CaffeNet"
layer {
name: "data"
type: "Data"
top: "data"
top: "label"
include {
phase: TRAIN
}
transform_param {
name: "CaffeNet"
layer {
name: "data"
type: "Input"
top: "data"
input_param { shape: { dim: 10 dim: 3 dim: 227 dim: 227 } }
}
layer {
name: "conv1"
type: "Convolution"
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@yrevar
yrevar / ocv_video_helper.py
Created April 23, 2017 17:46
OpenCV VideoCapture Helper
class VideoHelper(object):
def __init__(self, video_file, frame_start=0, frame_end=np.float('inf'), do_loop=True, preload_frames=1000):
self.preloaded = False
self.preload_frames = preload_frames
self._init_capture(video_file, frame_start, frame_end)
self.do_loop = do_loop
self.paused = False
import numpy as np
from search import *
## Flip-flop
class MaximizeAlternations(Problem):
def __init__(self, initial):
"""initial state is a numpy array with each element representing a bit 0 or 1,
goal state is same size as initial state with all bits turned 1"""
assert sum([n != 0 and n != 1 for n in initial]) == 0, "initial state must contain binary values."
self.initial = initial