Skip to content

Instantly share code, notes, and snippets.

View NoRaincheck's full-sized avatar

NoRaincheck

  • Nowhere
View GitHub Profile
@NoRaincheck
NoRaincheck / CATCH_Keras_RL.md
Created February 23, 2017 12:40 — forked from EderSantana/CATCH_Keras_RL.md
Keras plays catch - a single file Reinforcement Learning example
from keras.preprocessing.image import ImageDataGenerator, array_to_img, img_to_array, load_img
from keras.models import Sequential
from keras.layers import Convolution2D, MaxPooling2D
from keras.layers import Activation, Dropout, Flatten, Dense
train_data_dir = 'data'
img_width, img_height = 150, 150
train_datagen = ImageDataGenerator(

Topic list:

  • Zen of Python
  • dir
  • list vs tuple vs dict
  • iterating over things (continue, enumerate)
  • list comprehension (in)
  • dict comprehension (get)
  • **kwargs, *args
  • itertools and reading the recipes (e.g. list(itertools.chain.from_iterable(a)))
mu <- 2.5
tau <- 0.5
xn <- rnorm(50, mu, 1/tau)
# test for convergence
library(purrr)
mu_i = 0
alpha = 0.01
# stolen from stackoverflow, based on how james and i share scripts:
import Tkinter, tkSimpleDialog
root = Tkinter.Tk() # dialog needs a root window, or will create an "ugly" one for you
root.withdraw() # hide the root window
password = tkSimpleDialog.askstring("Password", "Enter password:", show='*', parent=root)
root.destroy() # clean up after yourself!
library(tidyverse)
data(iris)
func <- list(mean=mean, sd=sd, max=max, min=min)
fields <- c("Sepal.Length", "Sepal.Width")
# usage for one field
invoke_map(func, x=unlist(select_(iris, "Sepal.Length"))) %>% data.frame
# -*- coding: utf-8 -*-
"""
Created on Sun Oct 9 12:57:49 2016
@author: chapm
"""
import numpy as np
b = np.sqrt(2)
#!/usr/bin/env bash
# Copyright 2015 TappingStone, Inc.
#
# This script will install PredictionIO onto your computer!
#
# Documentation: http://docs.prediction.io
#
# License: http://www.apache.org/licenses/LICENSE-2.0
curl -i -XGET 'http://localhost:9200/_count?pretty' -d '
{
"query": {
"match_all": {}
}
}
'
# placing documents in {index:megacorp, type:employee, id:1}
curl -i -XPUT 'http://localhost:9200/megacorp/employee/1' -d '
sim <- function(nx, ny, tailorder=c(3,2), rdist=rnorm) {
xsample <- rdist(nx)
ysample <- rdist(ny)
xsample <- rev(xsample[order(xsample)])
ysample <- rev(ysample[order(ysample)])
return(xsample[tailorder[1]] > ysample[tailorder[2]])
}