diff options
Diffstat (limited to 'nerv/nn/layer_repo.lua')
-rw-r--r-- | nerv/nn/layer_repo.lua | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/nerv/nn/layer_repo.lua b/nerv/nn/layer_repo.lua index acef54a..647aac9 100644 --- a/nerv/nn/layer_repo.lua +++ b/nerv/nn/layer_repo.lua @@ -29,10 +29,21 @@ function LayerRepo:add_layers(layer_spec, param_repo, global_conf) end function LayerRepo:rebind(param_repo) - for id, layer in pairs(self.layers) do - layer.lconf.pr = param_repo - layer:bind_params() + if self.__rebinding then + return end + self.__rebinding = true + for _, layer in pairs(self.layers) do + if not layer.__already_rebound then + layer.__already_rebound = true + layer.lconf.pr = param_repo + layer:bind_params() + end + end + for _, layer in pairs(self.layers) do + layer.__already_rebound = false + end + self.__rebinding = false end function LayerRepo:get_layer(lid) |