Skip to content

Commit

Permalink
coding...
Browse files Browse the repository at this point in the history
  • Loading branch information
jzstark committed Jun 27, 2024
1 parent 26f2e06 commit 8b71fa9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
1 change: 0 additions & 1 deletion examples/README.md
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
The examples in this folder are made based on the OCaml's toplevel and Owl's Zoo system. Please refer to [Tutorial 9: Scripting and Zoo System](https://github.com/ryanrhymes/owl/wiki/Tutorial:-Scripting-and-Zoo-System).
8 changes: 4 additions & 4 deletions examples/computation_graph_02.ml
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@ let visualise_mnist () =
let _, adj0 = Graph.(backward network loss) in
let inputs = [| xt |> A.unpack_arr |> G.arr_to_node |] in
let s0_outputs = [| loss |> A.unpack_elt |> G.elt_to_node |] in
let s0 = G.make_graph inputs s0_outputs "mnist_loss" |> G.graph_to_dot in
let s0 = G.make_graph ~input:inputs ~output:s0_outputs "mnist_loss" |> G.graph_to_dot in
Owl_io.write_file "cgraph_04_mnist_loss.dot" s0;
Sys.command "dot -Tpdf cgraph_04_mnist_loss.dot -o cgraph_04_mnist_loss.pdf" |> ignore;
let s1_outputs = adj0
|> Utils.Array.flatten
|> Array.map (fun a -> A.unpack_arr a |> G.arr_to_node)
in
let s1 = G.make_graph inputs s1_outputs "mnist_loss" |> G.graph_to_dot in
let s1 = G.make_graph ~input:inputs ~output:s1_outputs "mnist_loss" |> G.graph_to_dot in
Owl_io.write_file "cgraph_04_mnist_grad.dot" s1;
Sys.command "dot -Tpdf cgraph_04_mnist_grad.dot -o cgraph_04_mnist_grad.pdf" |> ignore

Expand All @@ -67,14 +67,14 @@ let visualise_lstm () =
let _, adj0 = Graph.(backward network loss) in
let inputs = [| xt |> A.unpack_arr |> G.arr_to_node |] in
let s0_outputs = [| loss |> A.unpack_elt |> G.elt_to_node |] in
let s0 = G.make_graph inputs s0_outputs "mnist_loss" |> G.graph_to_dot in
let s0 = G.make_graph ~input:inputs ~output:s0_outputs "mnist_loss" |> G.graph_to_dot in
Owl_io.write_file "cgraph_04_lstm_loss.dot" s0;
(* Sys.command "dot -Tpdf -Gnslimit=1 cgraph_04_lstm_loss.dot -o cgraph_04_lstm_loss.pdf" |> ignore; *)
let s1_outputs = adj0
|> Utils.Array.flatten
|> Array.map (fun a -> A.unpack_arr a |> G.arr_to_node)
in
let s1 = G.make_graph inputs s1_outputs "mnist_loss" |> G.graph_to_dot in
let s1 = G.make_graph ~input:inputs ~output:s1_outputs "mnist_loss" |> G.graph_to_dot in
Owl_io.write_file "cgraph_04_lstm_grad.dot" s1
(* Sys.command "dot -Tpdf -Gnslimit=1 cgraph_04_lstm_grad.dot -o cgraph_04_lstm_grad.pdf" |> ignore *)

Expand Down

0 comments on commit 8b71fa9

Please sign in to comment.