added dilated convolution

This commit is contained in:
MohammadReza Hosseini
2020-06-14 18:49:10 +04:30
parent e20d3a0861
commit c51675bf44
5 changed files with 90 additions and 3 deletions
+4 -1
View File
@@ -24,6 +24,7 @@ namespace tk { namespace dnn {
int pad = 0;
int coords = 4;
float scale_xy = 1;
int dilation = 1;
std::vector<int> layers;
std::string activation = "linear";
@@ -115,6 +116,8 @@ namespace tk { namespace dnn {
auto vec = fromStringToIntVec(value, ',');
fields.n_mask = vec.size();
}
else if(name.find("dilation") != std::string::npos)
fields.dilation = std::stoi(value);
else if(name.find("layers") != std::string::npos)
fields.layers = fromStringToIntVec(value, ',');
@@ -143,7 +146,7 @@ namespace tk { namespace dnn {
std::string wgs = wgs_path + "/c" + std::to_string(netLayers.size()) + ".bin";
//printf("%d (%d,%d) (%d,%d) (%d,%d) %s %d %d\n", f.filters, f.size_x, f.size_y, f.stride_x, f.stride_y, f.padding_x, f.padding_y, wgs.c_str(), f.batch_normalize, f.groups);
tk::dnn::Conv2d *l= new tk::dnn::Conv2d(net, f.filters, f.size_x, f.size_y, f.stride_x,
f.stride_y, f.padding_x, f.padding_y, wgs, f.batch_normalize, false, f.groups);
f.stride_y, f.padding_x, f.padding_y, f.dilation, f.dilation, wgs, f.batch_normalize, false, f.groups);
netLayers.push_back(l);
} else if(f.type == "maxpool") {
if(f.stride_x == 1 && f.stride_y == 1)
+5
View File
@@ -261,6 +261,10 @@ public:
Conv2d( Network *net, int out_ch, int kernelH, int kernelW,
int strideH, int strideW, int paddingH, int paddingW,
std::string fname_weights, bool batchnorm = false, bool deConv = false, int groups = 1, bool additional_bias=false);
Conv2d( Network *net, int out_ch, int kernelH, int kernelW,
int strideH, int strideW, int paddingH, int paddingW,
int dilationW, int dilationH,
std::string fname_weights, bool batchnorm = false, bool deConv = false, int groups = 1, bool additional_bias=false);
virtual ~Conv2d();
virtual layerType_t getLayerType() { return LAYER_CONV2D; };
@@ -269,6 +273,7 @@ public:
int kernelH, kernelW, strideH, strideW, paddingH, paddingW;
bool deConv, additional_bias;
int groups;
int dilationW, dilationH;
protected:
cudnnFilterDescriptor_t filterDesc;