CIFAR10 VGG Example
This example demonstrates how to build a VGG-like convolutional neural network for CIFAR10 dataset.
| 5ca2fdebb0ccb9ecee6f4331972a9087 |
CIFAR10 VGG Example
This example demonstrates how to build a VGG-like convolutional neural network for CIFAR10 dataset.
| 217ef87bc36845c4e78e398d52bc4c5b |
| let x = Arr.sequential [|2;3;4|];; | |
| Owl_slicing_ext.(get_slice_list_typ [] x);; | |
| Owl_slicing_ext.(get_slice_list_typ [ R[]; R[]; R[]] x);; | |
| Owl_slicing_ext.(get_slice_list_typ [ I 1; R[]; R[]] x);; | |
| Owl_slicing_ext.(get_slice_list_typ [ I 1; I 2; R[]] x);; | |
| Owl_slicing_ext.(get_slice_list_typ [ I 1; I 0; I 3] x);; | |
| Owl_slicing_ext.(get_slice_list_typ [ I 1; I 0; I 2] x);; | |
| Owl_slicing_ext.(get_slice_list_typ [ L [0;1]; I 0; I 2] x);; | |
| Owl_slicing_ext.(get_slice_list_typ [ R [-1;0]; I 0; R []] x);; | |
| Owl_slicing_ext.(get_slice_list_typ [ R [-1;0]; I 0; R [1;2]] x);; |
| c18fdd78b99283a102a721a0fe4f214b |
| #require "owl_opencl";; | |
| let prog_s = " | |
| __kernel void hello_kernel(__global const float *a, | |
| __global const float *b, | |
| __global float *result) | |
| { | |
| int gid = get_global_id(0); | |
| result[gid] = a[gid] + b[gid]; | |
| } |
| #require "owl_opencl";; | |
| let x0 = Dense.Ndarray.S.uniform [|5;5|];; | |
| let x1 = Dense.Ndarray.S.uniform [|5;5|];; | |
| let x2 = Dense.Ndarray.S.uniform [|5;5|];; | |
| let x3 = Owl_opencl_dense.(add (Arr x0) (Arr x1));; | |
| let x4 = Owl_opencl_dense.(add x3 (Arr x2));; | |
| Owl_opencl_dense.eval x4;; |
| #require "owl_opencl";; | |
| open Owl_opencl_operand;; | |
| let x = Arr (Dense.Ndarray.S.uniform [|10;10|]);; | |
| let y = Owl_opencl_dense.add_scalar x (F 1.);; | |
| let z = Owl_opencl_dense.cos y;; | |
| eval z;; | |
| #require "owl_opencl";; | |
| open Owl_opencl_operand;; |
| module M = Owl_lazy.Make (Arr);; | |
| let x = Arr.uniform [|8;8|];; | |
| let a = M.of_ndarray x;; | |
| let b = M.(a |> sin |> cos);; | |
| M._eval_term b;; | |
| module M = Owl_lazy.Make (Arr);; | |
| let x = Arr.uniform [|8;8|];; | |
| let y = Arr.uniform [|8;8|];; |
| (* find the root inputs of [x] *) | |
| let find_roots x = | |
| let s = Owl_utils.Stack.make () in | |
| let rec _find x = | |
| Array.iter (fun n -> | |
| if n.op = Noop then Owl_utils.Stack.push s n | |
| else _find n | |
| ) x.prev | |
| in | |
| _find x; |