megengine.module.LocalConv2d¶
- class LocalConv2d(in_channels, out_channels, input_height, input_width, kernel_size, stride=1, padding=0, dilation=1, groups=1, conv_mode='cross_correlation', **kwargs)[源代码]¶
在输入的4D张量上使用多个untied kernel进行空域卷积。它也被称为局部连接层。
- 参数
in_channels (
int) – 输入数据中的通道数。out_channels (
int) – 输出数据中的通道数。input_height (
int) – 输入图像的高度。input_width (
int) – 输入图像的宽度。kernel_size (
Union[int,Tuple[int,int]]) – size of weight on spatial dimensions. If kernel_size is anint, the actual kernel size would be(kernel_size, kernel_size).padding (
Union[int,Tuple[int,int]]) – 输入数据空域维度两侧的填充(padding)大小。仅支持填充0值。默认:0groups (
int) – number of groups into which the input and output channels are divided, so as to perform a “grouped convolution”. Whengroupsis not 1,in_channelsandout_channelsmust be divisible bygroups. Default: 1
注解
weightusually has shape(out_height, out_width, in_channels, height, width, in_channels), if groups is not 1, shape will be(groups, out_height, out_width, in_channels // groups, height, width, out_channels // groups)biasusually has shape(1, out_channels, *1)
方法
apply(fn)对当前模块中的所有模块应用函数
fn,包括当前模块本身。buffers([recursive])返回该模块中对于buffers的一个可迭代对象。
calc_conv(inp, weight, bias)children(**kwargs)返回一个可迭代对象,可遍历所有属于当前模块的直接属性的子模块。
disable_quantize([value])设置
module的quantize_diabled属性,并返回module。eval()当前模块中所有模块的
training属性(包括自身)置为False,并将其切换为推理模式。forward(inp)load_state_dict(state_dict[, strict])加载一个参数字典,这个字典通常使用
state_dict得到。modules(**kwargs)返回一个可迭代对象,可以遍历当前模块中的所有模块,包括其本身。
named_buffers([prefix, recursive])返回可遍历模块中 key 与 buffer 的键值对的可迭代对象,其中
key为从该模块至 buffer 的点路径(dotted path)。named_children(**kwargs)返回可迭代对象,可以遍历属于当前模块的直接属性的所有子模块(submodule)与键(key)组成的”key-submodule”对,其中'key'是子模块对应的属性名。
named_modules([prefix])返回可迭代对象,可以遍历当前模块包括自身在内的所有其内部模块所组成的key-module键-模块对,其中'key'是从当前模块到各子模块的点路径(dotted path)。
named_parameters([prefix, recursive])返回一个可迭代对象,可以遍历当前模块中key与
Parameter组成的键值对。其中key是从模块到Parameter的点路径(dotted path)。named_tensors([prefix, recursive])Returns an iterable for key tensor pairs of the module, where
keyis the dotted path from this module to the tensor.parameters([recursive])返回一个可迭代对象,遍历当前模块中的所有
Parameterregister_forward_hook(hook)给模块输出注册一个回调函数。
给模块输入注册一个回调函数。
replace_param(params, start_pos[, seen])Replaces module's parameters with
params, used byParamPackto- rtype
state_dict([rst, prefix, keep_var])tensors([recursive])Returns an iterable for the
Tensorof the module.train([mode, recursive])当前模块中所有模块的
training属性(包括自身)置为mode。将所有参数的梯度置0。