diff --git a/src/convolutional_layer.c b/src/convolutional_layer.c index f9d66ebf..e784f5e4 100644 --- a/src/convolutional_layer.c +++ b/src/convolutional_layer.c @@ -745,6 +745,7 @@ void resize_convolutional_layer(convolutional_layer *l, int w, int h) //l->binary_input = realloc(l->inputs*l->batch, sizeof(float)); } + if (l->activation == SWISH || l->activation == MISH) l->activation_input = (float*)realloc(l->activation_input, total_batch*l->outputs * sizeof(float)); #ifdef GPU if (old_w < w || old_h < h) { if (l->train) { @@ -767,6 +768,9 @@ void resize_convolutional_layer(convolutional_layer *l, int w, int h) cuda_free(l->binary_input_gpu); l->binary_input_gpu = cuda_make_array(0, l->inputs*l->batch); } + + cuda_free(l->activation_input_gpu); + if (l->activation == SWISH || l->activation == MISH) l->activation_input_gpu = cuda_make_array(l->activation_input, total_batch*l->outputs); } #ifdef CUDNN cudnn_convolutional_setup(l, cudnn_fastest); diff --git a/src/dropout_layer.c b/src/dropout_layer.c index 0d34ed24..c32c5c61 100644 --- a/src/dropout_layer.c +++ b/src/dropout_layer.c @@ -27,11 +27,12 @@ dropout_layer make_dropout_layer(int batch, int inputs, float probability) void resize_dropout_layer(dropout_layer *l, int inputs) { + l->inputs = l->outputs = inputs; l->rand = (float*)realloc(l->rand, l->inputs * l->batch * sizeof(float)); #ifdef GPU cuda_free(l->rand_gpu); - l->rand_gpu = cuda_make_array(l->rand, inputs*l->batch); + l->rand_gpu = cuda_make_array(l->rand, l->inputs*l->batch); #endif } diff --git a/src/network.c b/src/network.c index c2249a54..96c935d9 100644 --- a/src/network.c +++ b/src/network.c @@ -535,8 +535,16 @@ int resize_network(network *net, int w, int h) resize_route_layer(&l, net); }else if (l.type == SHORTCUT) { resize_shortcut_layer(&l, w, h); - //}else if (l.type == SCALE_CHANNELS) { - // resize_scale_channels_layer(&l, w, h); + }else if (l.type == SCALE_CHANNELS) { + resize_scale_channels_layer(&l, net); + }else if (l.type == DROPOUT) { + resize_dropout_layer(&l, inputs); + l.output = net->layers[i - 1].output; + l.delta = net->layers[i - 1].delta; +#ifdef GPU + l.output_gpu = net->layers[i-1].output_gpu; + l.delta_gpu = net->layers[i-1].delta_gpu; +#endif }else if (l.type == UPSAMPLE) { resize_upsample_layer(&l, w, h); }else if(l.type == REORG){ @@ -556,9 +564,12 @@ int resize_network(network *net, int w, int h) if(l.workspace_size > workspace_size) workspace_size = l.workspace_size; inputs = l.outputs; net->layers[i] = l; - w = l.out_w; - h = l.out_h; - if(l.type == AVGPOOL) break; + if(l.type != DROPOUT) + { + w = l.out_w; + h = l.out_h; + } + //if(l.type == AVGPOOL) break; } #ifdef GPU const int size = get_network_input_size(*net) * net->batch; diff --git a/src/scale_channels_layer.c b/src/scale_channels_layer.c index 80be5361..bcb54c1b 100644 --- a/src/scale_channels_layer.c +++ b/src/scale_channels_layer.c @@ -39,10 +39,11 @@ layer make_scale_channels_layer(int batch, int index, int w, int h, int c, int w return l; } -void resize_scale_channels_layer(layer *l, int w, int h) +void resize_scale_channels_layer(layer *l, network *net) { - l->out_w = w; - l->out_h = h; + layer first = net->layers[l->index]; + l->out_w = first.out_w; + l->out_h = first.out_h; l->outputs = l->out_w*l->out_h*l->out_c; l->inputs = l->outputs; l->delta = (float*)realloc(l->delta, l->outputs * l->batch * sizeof(float)); diff --git a/src/scale_channels_layer.h b/src/scale_channels_layer.h index a20c0703..fdaa4b92 100644 --- a/src/scale_channels_layer.h +++ b/src/scale_channels_layer.h @@ -10,7 +10,7 @@ extern "C" { layer make_scale_channels_layer(int batch, int index, int w, int h, int c, int w2, int h2, int c2); void forward_scale_channels_layer(const layer l, network_state state); void backward_scale_channels_layer(const layer l, network_state state); -void resize_scale_channels_layer(layer *l, int w, int h); +void resize_scale_channels_layer(layer *l, network *net); #ifdef GPU void forward_scale_channels_layer_gpu(const layer l, network_state state);