Caffe
Public Member Functions | List of all members
caffe::BilinearFiller< Dtype > Class Template Reference

Fills a Blob with coefficients for bilinear interpolation. More...

#include <filler.hpp>

Inheritance diagram for caffe::BilinearFiller< Dtype >:
caffe::Filler< Dtype >

Public Member Functions

 BilinearFiller (const FillerParameter &param)
 
virtual void Fill (Blob< Dtype > *blob)
 
- Public Member Functions inherited from caffe::Filler< Dtype >
 Filler (const FillerParameter &param)
 

Additional Inherited Members

- Protected Attributes inherited from caffe::Filler< Dtype >
FillerParameter filler_param_
 

Detailed Description

template<typename Dtype>
class caffe::BilinearFiller< Dtype >

Fills a Blob with coefficients for bilinear interpolation.

A common use case is with the DeconvolutionLayer acting as upsampling. You can upsample a feature map with shape of (B, C, H, W) by any integer factor using the following proto.

layer {
name: "upsample", type: "Deconvolution"
bottom: "{{bottom_name}}" top: "{{top_name}}"
convolution_param {
kernel_size: {{2 * factor - factor % 2}} stride: {{factor}}
num_output: {{C}} group: {{C}}
pad: {{ceil((factor - 1) / 2.)}}
weight_filler: { type: "bilinear" } bias_term: false
}
param { lr_mult: 0 decay_mult: 0 }
}

Please use this by replacing {{}} with your values. By specifying num_output: {{C}} group: {{C}}, it behaves as channel-wise convolution. The filter shape of this deconvolution layer will be (C, 1, K, K) where K is kernel_size, and this filler will set a (K, K) interpolation kernel for every channel of the filter identically. The resulting shape of the top feature map will be (B, C, factor * H, factor * W). Note that the learning rate and the weight decay are set to 0 in order to keep coefficient values of bilinear interpolation unchanged during training. If you apply this to an image, this operation is equivalent to the following call in Python with Scikit.Image.

out = skimage.transform.rescale(img, factor, mode='constant', cval=0)

The documentation for this class was generated from the following file: