Skip to content

Instantly share code, notes, and snippets.

3-Layer MNIST Ver. 1 -- Repeat layer

Change 1-layer mnist data to 3 layers. Result: converge OK.

@jzstark
jzstark / load_cifar10.ml
Last active August 23, 2017 11:38
Test if the cifar10 dataset is loaded correctly
#!/usr/bin/env owl
#zoo "980a43a65e78613b4912c69008b3e909"
open Owl
let x, _, _ = Dataset.load_cifar_test_data () in
let x = Dense.Ndarray.Generic.cast_s2d x
|> Dense.Ndarray.D.get_slice_simple [[];[];[];[0]]
|> Dense.Ndarray.D.squeeze
in
@jzstark
jzstark / cifar10_full.ml
Last active August 16, 2017 17:15
CIFAR10 with full dataset
#!/usr/bin/env owl
open Owl
open Owl_neural
open Algodiff.S
open Owl_neural_neuron
let model () =
let open Owl_neural_graph in
let nn = input [|28;28;3|]
@jzstark
jzstark / cifar10_owl.ml
Last active August 23, 2017 11:38
An CNN example on CIFAR10 dataset with Owl
#!/usr/bin/env owl
open Owl
open Owl_neural
open Owl_neural_graph
open Algodiff.S
open Owl_neural_neuron
let model_name = "cifar10.model"
let test_batch = 10
@jzstark
jzstark / readme.md
Last active August 23, 2017 11:36
A general visualisation script for MNIST and CIFAR dataset

VisualModule

Visualize image dataset. Currently support MNIST and CIFAR10. visualize_dataset takes 2 arguments:

  1. imgs of type Dense.Ndarray.D.arr,
  2. len, of type int, for showing lenxlen images sample from the imgs
@jzstark
jzstark / #readme.md
Last active May 4, 2019 18:10
An implementation of InceptionV3 network with Owl

InceptionV3

InceptionV3 is one of Google’s latest effort to do image recognition. This is a standard task in computer vision, where models try to classify entire images into 1000 classes, like "Zebra", "Dalmatian", and "Dishwasher". Compared with previous DNN models, InceptionV3 has one of the most complex networks architectures in computer vision models. The original paper of this network is here.

Usage

This gist implements an InceptionV3 service in Owl, and provides simple interfaces to use. Here is an example:

#zoo "9428a62a31dbea75511882ab8218076f"
@jzstark
jzstark / inception_v3_weights_tf_dim_ordering_tf_kernels.h5
Last active August 29, 2017 18:15
Load N-dim array from Python/HDF5 to Owl/Ndarray
This file has been truncated, but you can view the full file.
#!/usr/bin/env owl
#zoo "980a43a65e78613b4912c69008b3e909" (*Import the VisualModule *)
(* Trains a simple convnet on the MNIST dataset. Network structure adapted from
* Keras example: https://github.com/fchollet/keras/blob/master/examples/mnist_cnn.py
*)
open Owl
open Owl_neural
open Algodiff.S
@jzstark
jzstark / loadImage.ml
Last active November 20, 2017 18:16
Load a (h * w) color image (.ppm format) into a [|h;w;3|] Ndarray into Owl
#!/usr/bin/env owl
open Owl
let _read_ppm fname =
(* grayscale binary ppm reading *)
let fp = open_in fname in
let ver = input_line fp in (* version *)
if ver <> "P6" then (* expect a .ppm file *)
# get the conv layers
cp owl_inception_structure.txt conv_structure.txt
sed -i.bak '/\[ Node conv2d/,/^\s*$/' conv_structure.txt
diff -biw conv_structure.txt owl_inception_structure.txt | sed -n 's/^> //p'