| 39 | const float default_wd = 0.0005f; |
| 40 | |
| 41 | LayerConf GenConvConf(string name, int nb_filter, int kernel, int stride, |
| 42 | int pad, float std = .02f, float bias = .0f) { |
| 43 | LayerConf conf; |
| 44 | conf.set_name(name); |
| 45 | conf.set_type(engine + "_convolution"); |
| 46 | ConvolutionConf *conv = conf.mutable_convolution_conf(); |
| 47 | conv->set_num_output(nb_filter); |
| 48 | conv->add_kernel_size(kernel); |
| 49 | conv->add_stride(stride); |
| 50 | conv->add_pad(pad); |
| 51 | conv->set_bias_term(true); |
| 52 | |
| 53 | ParamSpec *wspec = conf.add_param(); |
| 54 | wspec->set_name(name + "_weight"); |
| 55 | auto wfill = wspec->mutable_filler(); |
| 56 | wfill->set_type("Gaussian"); |
| 57 | wfill->set_std(sqrt(2.0f/(nb_filter*9.0f))); |
| 58 | |
| 59 | ParamSpec *bspec = conf.add_param(); |
| 60 | bspec->set_name(name + "_bias"); |
| 61 | auto bfill = bspec->mutable_filler(); |
| 62 | bfill->set_value(bias); |
| 63 | // bspec->set_lr_mult(2); |
| 64 | // bspec->set_decay_mult(0); |
| 65 | return conf; |
| 66 | } |
| 67 | |
| 68 | LayerConf GenPoolingConf(string name, bool max_pool, int kernel, int stride, |
| 69 | int pad) { |
no test coverage detected