#ifndef ResNet_H #define ResNet_H #include // BATCHNORM must be bn_con or affine layer template class BATCHNORM> struct resnet { // the resnet basic block, where BN is bn_con or affine template class BN, int stride, typename SUBNET> using basicblock = BN>>>>; // the resnet bottleneck block template class BN, int stride, typename SUBNET> using bottleneck = BN>>>>>>>; // the resnet residual template< template class, int, typename> class BLOCK, // basicblock or bottleneck long num_filters, template class BN, // bn_con or affine typename SUBNET > // adds the block to the result of tag1 (the subnet) using residual = dlib::add_prev1>>; // a resnet residual that does subsampling on both paths template< template class, int, typename> class BLOCK, // basicblock or bottleneck long num_filters, template class BN, // bn_con or affine typename SUBNET > using residual_down = dlib::add_prev2>>>>>; // residual block with optional downsampling and custom regularization (bn_con or affine) template< template class, int, typename> class, long, templateclass, typename> class RESIDUAL, template class, int, typename> class BLOCK, long num_filters, template class BN, // bn_con or affine typename SUBNET > using residual_block = dlib::relu>; template using resbasicblock_down = residual_block; template using resbottleneck_down = residual_block; // some definitions to allow the use of the repeat layer template using resbasicblock_512 = residual_block; template using resbasicblock_256 = residual_block; template using resbasicblock_128 = residual_block; template using resbasicblock_64 = residual_block; template using resbottleneck_512 = residual_block; template using resbottleneck_256 = residual_block; template using resbottleneck_128 = residual_block; template using resbottleneck_64 = residual_block; // common processing for standard resnet inputs template class BN, typename INPUT> using input_processing = dlib::max_pool<3, 3, 2, 2, dlib::relu>>>; // the resnet backbone with basicblocks template using backbone_basicblock = dlib::repeat>>>>>>>; // the resnet backbone with bottlenecks template using backbone_bottleneck = dlib::repeat>>>>>>>; // the backbones for the classic architectures template using backbone_18 = backbone_basicblock<1, 1, 1, 2, INPUT>; template using backbone_34 = backbone_basicblock<2, 5, 3, 3, INPUT>; template using backbone_50 = backbone_bottleneck<2, 5, 3, 3, INPUT>; template using backbone_101 = backbone_bottleneck<2, 22, 3, 3, INPUT>; template using backbone_152 = backbone_bottleneck<2, 35, 7, 3, INPUT>; // the typical classifier models using n18 = dlib::loss_multiclass_log>>>; using n34 = dlib::loss_multiclass_log>>>; using n50 = dlib::loss_multiclass_log>>>; using n101 = dlib::loss_multiclass_log>>>; using n152 = dlib::loss_multiclass_log>>>; }; #endif // ResNet_H