From 9ac78d8b84f6a059d2cefe22a10aa60de5b3feaf Mon Sep 17 00:00:00 2001 From: AlexeyAB Date: Fri, 5 Jan 2018 00:58:52 +0300 Subject: [PATCH] Fine tuning, use stopbackward=1 in the cfg-file in that layer where Backward should be stopped. --- src/layer.h | 2 ++ src/network.c | 1 + src/network_kernels.cu | 1 + src/parser.c | 2 ++ 4 files changed, 6 insertions(+) diff --git a/src/layer.h b/src/layer.h index eb480c00..285abe3e 100644 --- a/src/layer.h +++ b/src/layer.h @@ -122,6 +122,8 @@ struct layer{ int classfix; int absolute; + int onlyforward; + int stopbackward; int dontload; int dontloadscales; diff --git a/src/network.c b/src/network.c index 2d755ae3..56a316ca 100644 --- a/src/network.c +++ b/src/network.c @@ -218,6 +218,7 @@ void backward_network(network net, network_state state) state.delta = prev.delta; } layer l = net.layers[i]; + if (l.stopbackward) break; l.backward(l, state); } } diff --git a/src/network_kernels.cu b/src/network_kernels.cu index 313cd6d1..7a261c57 100644 --- a/src/network_kernels.cu +++ b/src/network_kernels.cu @@ -64,6 +64,7 @@ void backward_network_gpu(network net, network_state state) for(i = net.n-1; i >= 0; --i){ state.index = i; layer l = net.layers[i]; + if (l.stopbackward) break; if(i == 0){ state.input = original_input; state.delta = original_delta; diff --git a/src/parser.c b/src/parser.c index e0fe8f20..9fc4966c 100644 --- a/src/parser.c +++ b/src/parser.c @@ -672,6 +672,8 @@ network parse_network_cfg_custom(char *filename, int batch) }else{ fprintf(stderr, "Type not recognized: %s\n", s->type); } + l.onlyforward = option_find_int_quiet(options, "onlyforward", 0); + l.stopbackward = option_find_int_quiet(options, "stopbackward", 0); l.dontload = option_find_int_quiet(options, "dontload", 0); l.dontloadscales = option_find_int_quiet(options, "dontloadscales", 0); option_unused(options);