From a81c652aab0cfc22f5acddcb0dea23888b72378c Mon Sep 17 00:00:00 2001 From: nirmal Date: Wed, 7 Oct 2020 21:40:18 +0530 Subject: [PATCH] Improve fit_mesh tutorial --- docs/src/tutorials/fit_mesh.md | 4 ++-- examples/fit_mesh.jl | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/docs/src/tutorials/fit_mesh.md b/docs/src/tutorials/fit_mesh.md index 8c94b93..c3fb900 100644 --- a/docs/src/tutorials/fit_mesh.md +++ b/docs/src/tutorials/fit_mesh.md @@ -99,6 +99,7 @@ end ```julia lr = 1.0 opt = Flux.Optimise.Momentum(lr, 0.9) +_offset = zeros(Float32, size(get_verts_packed(src))...) ``` ## Using GPU for fast training [**Optional**] @@ -108,7 +109,7 @@ function which is exactly the same syntax as Flux. ```julia tgt = tgt |> gpu src = src |> gpu -_offset = zeros(Float32, size(get_verts_packed(src))...) |> gpu +_offset = _offset |> gpu ``` ## Optimizing the offset array @@ -179,4 +180,3 @@ metrics. --- *This page was generated using [Literate.jl](https://github.com/fredrikekre/Literate.jl).* - diff --git a/examples/fit_mesh.jl b/examples/fit_mesh.jl index 2886c36..8e5ca83 100644 --- a/examples/fit_mesh.jl +++ b/examples/fit_mesh.jl @@ -86,6 +86,7 @@ end lr = 1.0 opt = Flux.Optimise.Momentum(lr, 0.9) +_offset = zeros(Float32, size(get_verts_packed(src))...) # ## Using GPU for fast training [**Optional**] # We can convert the TriMesh structure to GPU or CPU using`gpu` and `cpu` @@ -93,7 +94,7 @@ opt = Flux.Optimise.Momentum(lr, 0.9) tgt = tgt |> gpu src = src |> gpu -_offset = zeros(Float32, size(get_verts_packed(src))...) |> gpu +_offset = _offset |> gpu # ## Optimizing the offset array # We first initialize offset array as zeros, hence deformed mesh is equivalent to