Skip to content

Instantly share code, notes, and snippets.

@jzstark
jzstark / import_graph_tf.py
Created May 31, 2017 17:36
Tensorflow support for import graph:
# DATA_URL = 'http://download.tensorflow.org/models/image/imagenet/inception-2015-12-05.tgz'
def create_graph():
"""Creates a graph from saved GraphDef file and returns a saver."""
# Creates graph from saved graph_def.pb.
with tf.gfile.FastGFile('classify_image_graph_def.pb', 'rb') as f:
graph_def = tf.GraphDef()
graph_def.ParseFromString(f.read())
_ = tf.import_graph_def(graph_def, name='')
@jzstark
jzstark / extended_line.png
Last active June 30, 2017 20:58
qqplot and example
extended_line.png
@jzstark
jzstark / probplot.ml
Last active July 4, 2017 14:19
Probability Plot
(*A good example*)
let y = Mat.(gaussian 100 1 *$ 10.) in
let h = create "" in
let _ = set_background_color h 28 28 28 in
let _ = set_title h "Gaussian Data to fit Weibull Dist" in
let _ = set_xlabel h "Sample Data" in
let _ = set_ylabel h "Theoratical Weibull Distribution invCdf" in
let _ = probplot ~h ~dist:(fun i -> Owl_stats.Cdf.weibull_Pinv i 1. 1.) y in
output h;;
(*example*)
(*Add logscale: Add xlogscale and ylogscale properties to a page;
The logdata still needs to be precomputed.*)
let x = Mat.logspace (-1.) 2. 10 in
let y = Mat.map Maths.exp x in
let z = Mat.log10 y in
let h = create "log4.pdf" in
let _ = scatter ~h ~color:(255,0,0)~marker:"#[0x2299]" ~marker_size:8. x z in
@jzstark
jzstark / plot_024.png
Last active July 19, 2017 15:52
Figures for owl_plot
plot_024.png
@jzstark
jzstark / durer.txt
Last active July 19, 2017 21:57
Image Plot
This file has been truncated, but you can view the full file.
231 210 156 159 159 159 160 154 166 163 166 167 160 168 171 175 170 166 175 167 169 175 165 168 169 166 177 174 167 169 172 177 175 171 173 172 161 167 175 172 167 177 172 169 169 171 170 180 172 172 171 167 177 178 173 183 166 173 171 175 175 169 173 173 170 166 170 172 164 172 171 171 174 168 170 177 162 169 174 160 165 172 172 174 173 174 174 172 170 171 175 168 182 170 172 166 179 176 172 171 170 175 177 169 170 175 172 173 171 176 173 177 177 187 170 179 177 181 181 177 181 176 183 179 182 188 182 183 184 186 188 182 186 182 183 184 182 191 184 189 187 189 185 185 184 190 192 193 190 187 192 185 185 186 191 188 199 191 197 193 197 202 185 198 196 189 197 198 184 201 201 199 192 205 196 204 201 206 208 208 203 199 217 205 205 204 213 204 210 201 221 205 213 208 218 212 215 211 215 213 218 211 216 218 210 226 217 212 218 220 214 222 222 227 219 222 218 216 221 224 218 214 222 224 214 219 220 222 219 216 228 219 225 225 226 223 225 222 219 227 220 234 207 221 217 227 217 228 220 227 219 232 218 230 221 225
@jzstark
jzstark / cifar10_keras.ml
Last active August 14, 2017 16:32
A Neural network on CIFAR-10 dataset adopted from Keras/example (unfinished)
open Owl
open Owl_neural
open Algodiff.S
open Owl_neural_neuron
(*
let test_cnn nn x y =
for i = 0 to 9 do
let u = Dense.Ndarray.S.slice [[i]] x in
Dense.Ndarray.S.reshape u [|3;32;32|]
open Owl_neural
open Owl_neural_graph
open Algodiff.S
open Owl_neural_neuron
open Plplot
let x, y = Dataset.load_cifar_train_data 1
let m = Dense.Matrix.S.row_num x
let num_test = 9
@jzstark
jzstark / imdb.ml
Last active July 31, 2017 22:56
load IMDB sentiment dataset
(* source: http://ai.stanford.edu/~amaas/data/sentiment/ *)
let vocab_file = "imdb.vocab"
let load_file f =
let ic = open_in f in
let n = in_channel_length ic in
let s = Bytes.create n in
really_input ic s 0 n;
close_in ic;
(*
Example script to generate text from Nietzsche's writings.
At least 20 epochs are required before the generated text
starts sounding coherent.
It is recommended to run this script on GPU, as recurrent
networks are quite computationally intensive.
Adapted from Keras example: lstm_text_generation.py
*)