Skip to content

Instantly share code, notes, and snippets.

View stokasto's full-sized avatar

Jost Tobias Springenberg stokasto

View GitHub Profile
@stokasto
stokasto / catgan_objective_illustration.py
Created January 7, 2016 20:19
Illustration of the behavior of the CatGAN objective function for the example from the rebuttal
import numpy as np
def class_entropy(X):
class_prob = np.mean(X, axis = 0)
return -np.sum(class_prob * np.log(class_prob + 1e-4))
def cond_entropy(X):
return -np.mean(np.sum(X * np.log(X + 1e-4), axis=1))
def cross_entropy(X, Y):
@stokasto
stokasto / read_video.py
Created February 9, 2012 10:44
convert video to numpy array
from numpy import *
import cv
capture = cv.CaptureFromFile('video.mov')
frames = []
for i in range(100):
img = cv.QueryFrame(capture)
tmp = cv.CreateImage(cv.GetSize(img),8,3)
cv.CvtColor(img,tmp,cv.CV_BGR2RGB)
frames.append(asarray(cv.GetMat(tmp)))