Skip to content

Instantly share code, notes, and snippets.

View kashif's full-sized avatar

Kashif Rasul kashif

  • Berlin, Germany
  • 04:04 (UTC +01:00)
  • X @krasul
View GitHub Profile
@kashif
kashif / fashion_mnist_cnn.py
Last active October 26, 2022 22:04
Fashion Mnist Benchmark
'''Trains a simple convnet on the Zalando MNIST dataset.
Gets to 81.03% test accuracy after 30 epochs
(there is still a lot of margin for parameter tuning).
3 seconds per epoch on a GeForce GTX 980 GPU with CuDNN 5.
'''
from __future__ import print_function
import numpy as np
from mnist import MNIST
@kashif
kashif / es.py
Last active June 5, 2017 12:07
Initial implementation of Evolution Strategies
import numpy as np
import gym
from gym.spaces import Discrete, Box
from gym.wrappers import Monitor
from keras.models import Sequential
from keras.layers import Dense, Activation, Flatten
# ================================================================
# Policies
name: "autocolorize"
input: "data"
input_dim: 1
input_dim: 1
input_dim: 514
input_dim: 514
layer {
name: "data"
type: "Input"
top: "data"
@kashif
kashif / cem.md
Last active November 7, 2023 12:56
Cross Entropy Method

Cross Entropy Method

How do we solve for the policy optimization problem which is to maximize the total reward given some parametrized policy?

Discounted future reward

To begin with, for an episode the total reward is the sum of all the rewards. If our environment is stochastic, we can never be sure if we will get the same rewards the next time we perform the same actions. Thus the more we go into the future the more the total future reward may diverge. So for that reason it is common to use the discounted future reward where the parameter discount is called the discount factor and is between 0 and 1.

A good strategy for an agent would be to always choose an action that maximizes the (discounted) future reward. In other words we want to maximize the expected reward per episode.

@kashif
kashif / cifar10_wide_resnet.py
Last active May 10, 2021 02:44
Keras Wide Residual Networks CIFAR-10
from __future__ import print_function
from keras.datasets import cifar10
from keras.layers import merge, Input
from keras.layers.convolutional import Convolution2D, ZeroPadding2D, AveragePooling2D
from keras.layers.core import Dense, Activation, Flatten, Dropout
from keras.layers.normalization import BatchNormalization
from keras.models import Model
from keras.preprocessing.image import ImageDataGenerator
from keras.utils import np_utils
@kashif
kashif / cifar10_resnet.py
Last active February 3, 2021 09:06
Keras Pre-activation Residual Network for CIFAR-10
from __future__ import print_function
from keras.datasets import cifar10
from keras.layers import merge, Input
from keras.layers.convolutional import Convolution2D, ZeroPadding2D, AveragePooling2D
from keras.layers.core import Dense, Activation, Flatten
from keras.layers.normalization import BatchNormalization
from keras.models import Model
from keras.preprocessing.image import ImageDataGenerator
from keras.utils import np_utils
@kashif
kashif / Softwareprojekte.md
Created February 26, 2013 20:57
Softwareprojekte for SpacialDB
  • a short description of your company and what you do/offer
  • a detailed description of the students tasks/project
  • requirements (knowledge of, e. g. Spatial DB course, programming skills)
  • task/project plans (what will they do?)
  • what are the students going to work with/learn:
  • programming languages
  • infrastructure (versioning system, build system)
@kashif
kashif / gist:1724880
Created February 2, 2012 18:00
unix bench
========================================================================
BYTE UNIX Benchmarks (Version 5.1.3)
System: europe.spacialdb.com: GNU/Linux
OS: GNU/Linux -- 3.0.0-12-server -- #20-Ubuntu SMP Fri Oct 7 16:36:30 UTC 2011
Machine: x86_64 (x86_64)
Language: en_US.utf8 (charmap="UTF-8", collate="UTF-8")
CPU 0: Intel(R) Core(TM) i7 CPU 920 @ 2.67GHz (5346.4 bogomips)
Hyper-Threading, x86-64, MMX, Physical Address Ext, SYSENTER/SYSEXIT, SYSCALL/SYSRET, Intel virtualization
CPU 1: Intel(R) Core(TM) i7 CPU 920 @ 2.67GHz (5346.4 bogomips)
@kashif
kashif / hs_2json.sql
Created January 31, 2012 10:10
Another hstore to JSON function by Andrew Dunstan
create or replace function hs_2json(hs hstore) returns text language sql
as $f$
select '{' || array_to_string(array_agg(
'"' || regexp_replace(key,E'[\\"]',E'\\\&','g') || '":' ||
case
when value is null then 'null'
when value ~ '^(true|false|(-?(0|[1-9]\d*)(\.\d+)?([eE][+-]?\d+)?))$' then value
else '"' || regexp_replace(value,E'[\\"]',E'\\\&','g') || '"'
end
@kashif
kashif / hstore_to_json.sql
Created January 20, 2012 22:14
Another hstore to JSON function by Andrew Dunstan
create or replace function hstore_to_json(h hstore) returns text language sql
as $f$
select '{' || array_to_string(array_agg(
'"' || regexp_replace(key,E'[\\"]',E'\\\&','g') || '":' ||
case
when value is null then 'null'
when value ~ '^true|false|(-?(0|[1-9]\d*)(\.\d+)?([eE][+-]?\d+)?)$' then value
else '"' || regexp_replace(value,E'[\\"]',E'\\\&','g') || '"'
end