basecls.layers.modules#

basecls.layers.modules.conv2d(w_in, w_out, k, *, stride=1, dilation=1, groups=1, bias=False)[源代码]#

Helper for building a conv2d layer.

It will calculate padding automatically.

参数
  • w_in (int) – input width.

  • w_out (int) – output width.

  • k (int) – kernel size.

  • stride (int) – stride. Default: 1

  • dilation (int) – dilation. Default: 1

  • groups (int) – groups. Default: 1

  • bias (bool) – enable bias or not. Default: False

返回类型

Conv2d

返回

A conv2d module.

basecls.layers.modules.norm2d(name, w_in, **kwargs)[源代码]#

Helper for building a norm2d layer.

参数
  • norm_name – normalization name, supports None, "BN", "GN", "IN", "LN" and "SyncBN".

  • w_in (int) – input width.

返回类型

Module

返回

A norm2d module.

basecls.layers.modules.pool2d(k, *, stride=1, name='max')[源代码]#

Helper for building a pool2d layer.

参数
  • k (int) – kernel size.

  • stride (int) – stride. Default: 1

  • name (str) – pooling name, supports "avg" and "max".

返回类型

Module

返回

A pool2d module.

basecls.layers.modules.gap2d(shape=1)[源代码]#

Helper for building a gap2d layer.

参数

shape – output shape. Default: 1

返回类型

AdaptiveAvgPool2d

返回

A gap2d module.

basecls.layers.modules.linear(w_in, w_out, *, bias=False)[源代码]#

Helper for building a linear layer.

参数
  • w_in (int) – input width.

  • w_out (int) – output width.

  • bias (bool) – enable bias or not. Default: False

返回类型

Linear

返回

A linear module.

class basecls.layers.modules.SE(w_in, w_se, act_name, approx_sigmoid=False)[源代码]#

基类:Module

Squeeze-and-Excitation (SE) block: AvgPool, FC, Act, FC, Sigmoid.

参数
  • w_in (int) – input width.

  • w_se (int) – se width.

  • act_name (str) – activation name.

  • approx_sigmoid (bool) – approximated sigmoid function.

avg_pool#

gad2d layer.

f_ex#

sequantial which conbines conv2d -> act -> conv2d -> sigmoid.

forward(x)[源代码]#
返回类型

Tensor

class basecls.layers.modules.DropPath(drop_prob=0.0, **kwargs)[源代码]#

基类:Dropout

DropPath block.

参数

drop_prob – the probability to drop (set to zero) each path.

forward(x)[源代码]#