015b435553d1591378233dfe8792027d910d56eb,batchflow/models/eager_torch/resnet.py,ResBlock,__init__,#ResBlock#Any#Any#Any#Any#Any#Any#Any#Any#Any#Any#Any#,69
Before Change
num_convs = sum([letter in CONV_LETTERS for letter in layout])
vars = {key: get_num_channels(inputs) for key in ["S", "same"]}
filters = [filters] * num_convs if isinstance(filters, (int, str)) else filters
filters = [eval(str(item), {}, vars) for item in filters]
kernel_size = [kernel_size] * num_convs if isinstance(kernel_size, int) else kernel_size
strides = [strides] * num_convs if isinstance(strides, int) else strides
strides_d = list(strides)
groups = [groups] * num_convs
side_branch_stride = np.prod(strides)
side_branch_stride_d = int(side_branch_stride)
if downsample:
downsample = 2 if downsample is True else downsample
strides_d[0] *= downsample
side_branch_stride_d *= downsample
if bottleneck:
bottleneck = 4 if bottleneck is True else bottleneck
layout = "cna" + layout + "cna"
kernel_size = [1] + kernel_size + [1]
strides = [1] + strides + [1]
strides_d = [1] + strides_d + [1]
groups = [1] + groups + [1]
filters = [filters[0] // bottleneck] + filters + [filters[0]]
if se:
layout += "S*"
layout = "B" + layout + op
layer_params = [{"strides": strides_d, "side_branch/strides": side_branch_stride_d}] + [{}]*(n_reps-1)
self.block = ConvBlock(*layer_params, inputs=inputs, layout=layout, filters=filters,
kernel_size=kernel_size, strides=strides, groups=groups,
side_branch={"layout": "c", "filters": filters[-1], "strides": side_branch_stride},
**kwargs)
After Change
num_convs = sum([letter in CONV_LETTERS for letter in layout])
filters = [filters] * num_convs if isinstance(filters, (int, str)) else filters
filters = [safe_eval(str(item), get_num_channels(inputs)) for item in filters]
kernel_size = [kernel_size] * num_convs if isinstance(kernel_size, int) else kernel_size
strides = [strides] * num_convs if isinstance(strides, int) else strides
strides_d = list(strides)
groups = [groups] * num_convs
side_branch_stride = np.prod(strides)
side_branch_stride_d = int(side_branch_stride)
if downsample:
downsample = 2 if downsample is True else downsample
strides_d[0] *= downsample
side_branch_stride_d *= downsample
if bottleneck:
bottleneck = 4 if bottleneck is True else bottleneck
layout = "cna" + layout + "cna"
kernel_size = [1] + kernel_size + [1]
strides = [1] + strides + [1]
strides_d = [1] + strides_d + [1]
groups = [1] + groups + [1]
filters = [filters[0] // bottleneck] + filters + [filters[0]]
if se:
layout += "S*"
layout = "B" + layout + op
layer_params = [{"strides": strides_d, "side_branch/strides": side_branch_stride_d}] + [{}]*(n_reps-1)
self.block = ConvBlock(*layer_params, inputs=inputs, layout=layout, filters=filters,
kernel_size=kernel_size, strides=strides, groups=groups,
side_branch={"layout": "c", "filters": filters[-1], "strides": side_branch_stride},
**kwargs)
In pattern: SUPERPATTERN
Frequency: 3
Non-data size: 12
Instances
Project Name: analysiscenter/batchflow
Commit Name: 015b435553d1591378233dfe8792027d910d56eb
Time: 2019-12-05
Author: Tsimfer.SA@gazprom-neft.ru
File Name: batchflow/models/eager_torch/resnet.py
Class Name: ResBlock
Method Name: __init__
Project Name: analysiscenter/batchflow
Commit Name: 9182eb9b800fdec1581538be4addba969717601b
Time: 2019-12-07
Author: Tsimfer.SA@gazprom-neft.ru
File Name: batchflow/models/eager_torch/blocks.py
Class Name: DenseBlock
Method Name: __init__
Project Name: analysiscenter/batchflow
Commit Name: 015b435553d1591378233dfe8792027d910d56eb
Time: 2019-12-05
Author: Tsimfer.SA@gazprom-neft.ru
File Name: batchflow/models/eager_torch/layers/conv.py
Class Name: BaseConv
Method Name: __init__