| | |
| | | return layer; |
| | | } |
| | | |
| | | void forward_crop_layer(const crop_layer layer, float *input) |
| | | void forward_crop_layer(const crop_layer layer, network_state state) |
| | | { |
| | | int i,j,c,b,row,col; |
| | | int index; |
| | | int count = 0; |
| | | int flip = (layer.flip && rand()%2); |
| | | int dh = rand()%(layer.h - layer.crop_height); |
| | | int dw = rand()%(layer.w - layer.crop_width); |
| | | int dh = rand()%(layer.h - layer.crop_height + 1); |
| | | int dw = rand()%(layer.w - layer.crop_width + 1); |
| | | if(!state.train){ |
| | | flip = 0; |
| | | dh = (layer.h - layer.crop_height)/2; |
| | | dw = (layer.w - layer.crop_width)/2; |
| | | } |
| | | for(b = 0; b < layer.batch; ++b){ |
| | | for(c = 0; c < layer.c; ++c){ |
| | | for(i = 0; i < layer.crop_height; ++i){ |
| | |
| | | } |
| | | row = i + dh; |
| | | index = col+layer.w*(row+layer.h*(c + layer.c*b)); |
| | | layer.output[count++] = input[index]; |
| | | layer.output[count++] = state.input[index]; |
| | | } |
| | | } |
| | | } |