self.list_layers.remove()动态删除感觉有点问题
SWHL opened this issue · 2 comments
SWHL commented
如果self.list_layers
中的层名称中有几层是这样的:
conv1_weights
conv1_bn_variance
conv1_bn_mean
conv1_bn_scale
conv1_bn_offset
conv2_expand_weights
conv2_expand_bn_mean
conv2_expand_bn_scale
- 因为remove是动态删除list
- 如果刚操作了
conv1_bn_variance
,→ self.list_layers.remove('conv1_bn_variance'),就会变为这样:
conv1_weights
conv1_bn_mean
conv1_bn_scale
conv1_bn_offset
conv2_expand_weights
conv2_expand_bn_mean
conv2_expand_bn_scale
- 但是此刻,该遍历
conv1_bn_scale
,就会丢失conv1_bn_mean
maomaoyuchengzi commented
如果
self.list_layers
中的层名称中有几层是这样的:conv1_weights conv1_bn_variance conv1_bn_mean conv1_bn_scale conv1_bn_offset conv2_expand_weights conv2_expand_bn_mean conv2_expand_bn_scale
- 因为remove是动态删除list
- 如果刚操作了
conv1_bn_variance
,→ self.list_layers.remove('conv1_bn_variance'),就会变为这样:conv1_weights conv1_bn_mean conv1_bn_scale conv1_bn_offset conv2_expand_weights conv2_expand_bn_mean conv2_expand_bn_scale
- 但是此刻,该遍历
conv1_bn_scale
,就会丢失conv1_bn_mean
没问题的,你可以打印试试看;
SWHL commented
感谢这么快回复
如果方便的话,可以跑一下这个模型,我这边刚跑了
我在
下面加了打印代码:
print('=' * 30)
for layer in self.list_layers:
print(f'未成功转换层:{layer}')
打印出结果如下:
- 从结果中可以看到
conv1_bn_offset,conv1_bn_variance
等许多bn层未成功转换
conv1_bn_scale
conv1_bn_mean
conv2_expand_weights
conv2_expand_bn_scale
conv2_expand_bn_mean
conv2_depthwise_weights
conv2_depthwise_bn_scale
conv2_depthwise_bn_mean
conv2_se_1_weights
conv2_se_2_weights
conv2_linear_weights
conv2_linear_bn_scale
conv2_linear_bn_mean
conv3_expand_weights
conv3_expand_bn_scale
conv3_expand_bn_mean
conv3_depthwise_weights
conv3_depthwise_bn_scale
conv3_depthwise_bn_mean
conv3_linear_weights
conv3_linear_bn_scale
conv3_linear_bn_mean
conv4_expand_weights
conv4_expand_bn_scale
conv4_expand_bn_mean
conv4_depthwise_weights
conv4_depthwise_bn_scale
conv4_depthwise_bn_mean
conv4_linear_weights
conv4_linear_bn_scale
conv4_linear_bn_mean
conv5_expand_weights
conv5_expand_bn_scale
conv5_expand_bn_mean
conv5_depthwise_weights
conv5_depthwise_bn_scale
conv5_depthwise_bn_mean
conv5_se_1_weights
conv5_linear_weights
conv5_linear_bn_scale
conv5_linear_bn_mean
conv6_expand_weights
conv6_expand_bn_scale
conv6_expand_bn_mean
conv6_depthwise_weights
conv6_depthwise_bn_scale
conv6_depthwise_bn_mean
conv6_se_1_weights
conv6_linear_weights
conv6_linear_bn_scale
conv6_linear_bn_mean
conv7_expand_weights
conv7_expand_bn_scale
conv7_expand_bn_mean
conv7_depthwise_weights
conv7_depthwise_bn_scale
conv7_depthwise_bn_mean
conv7_se_1_weights
conv7_linear_weights
conv7_linear_bn_scale
conv7_linear_bn_mean
conv8_expand_weights
conv8_expand_bn_scale
conv8_expand_bn_mean
conv8_depthwise_weights
conv8_depthwise_bn_scale
conv8_depthwise_bn_mean
conv8_se_1_weights
conv8_linear_weights
conv8_linear_bn_scale
conv8_linear_bn_mean
conv9_expand_weights
conv9_expand_bn_scale
conv9_expand_bn_mean
conv9_depthwise_weights
conv9_depthwise_bn_scale
conv9_depthwise_bn_mean
conv9_se_1_weights
conv9_linear_weights
conv9_linear_bn_scale
conv9_linear_bn_mean
conv10_expand_weights
conv10_expand_bn_scale
conv10_expand_bn_mean
conv10_depthwise_weights
conv10_depthwise_bn_scale
conv10_depthwise_bn_mean
conv10_se_1_weights
conv10_linear_weights
conv10_linear_bn_scale
conv10_linear_bn_mean
conv11_expand_weights
conv11_expand_bn_scale
conv11_expand_bn_mean
conv11_depthwise_weights
conv11_depthwise_bn_scale
conv11_depthwise_bn_mean
conv11_se_1_weights
conv11_linear_weights
conv11_linear_bn_scale
conv11_linear_bn_mean
conv12_expand_weights
conv12_expand_bn_scale
conv12_expand_bn_mean
conv12_depthwise_weights
conv12_depthwise_bn_scale
conv12_depthwise_bn_mean
conv12_se_1_weights
conv12_se_2_weights
conv12_linear_weights
conv12_linear_bn_scale
conv12_linear_bn_mean
==============================
未成功转换层:conv1_bn_offset
未成功转换层:conv1_bn_variance
未成功转换层:conv2_expand_bn_offset
未成功转换层:conv2_expand_bn_variance
未成功转换层:conv2_depthwise_bn_offset
未成功转换层:conv2_depthwise_bn_variance
未成功转换层:conv2_se_1_offset
未成功转换层:conv2_se_2_offset
未成功转换层:conv2_linear_bn_offset
未成功转换层:conv2_linear_bn_variance
未成功转换层:conv3_expand_bn_offset
未成功转换层:conv3_expand_bn_variance
未成功转换层:conv3_depthwise_bn_offset
未成功转换层:conv3_depthwise_bn_variance
未成功转换层:conv3_linear_bn_offset
未成功转换层:conv3_linear_bn_variance
未成功转换层:conv4_expand_bn_offset
未成功转换层:conv4_expand_bn_variance
未成功转换层:conv4_depthwise_bn_offset
未成功转换层:conv4_depthwise_bn_variance
未成功转换层:conv4_linear_bn_offset
未成功转换层:conv4_linear_bn_variance
未成功转换层:conv5_expand_bn_offset
未成功转换层:conv5_expand_bn_variance
未成功转换层:conv5_depthwise_bn_offset
未成功转换层:conv5_depthwise_bn_variance
未成功转换层:conv5_se_1_offset
未成功转换层:conv5_se_2_weights
未成功转换层:conv5_se_2_offset
未成功转换层:conv5_linear_bn_offset
未成功转换层:conv5_linear_bn_variance
未成功转换层:conv6_expand_bn_offset
未成功转换层:conv6_expand_bn_variance
未成功转换层:conv6_depthwise_bn_offset
未成功转换层:conv6_depthwise_bn_variance
未成功转换层:conv6_se_1_offset
未成功转换层:conv6_se_2_weights
未成功转换层:conv6_se_2_offset
未成功转换层:conv6_linear_bn_offset
未成功转换层:conv6_linear_bn_variance
未成功转换层:conv7_expand_bn_offset
未成功转换层:conv7_expand_bn_variance
未成功转换层:conv7_depthwise_bn_offset
未成功转换层:conv7_depthwise_bn_variance
未成功转换层:conv7_se_1_offset
未成功转换层:conv7_se_2_weights
未成功转换层:conv7_se_2_offset
未成功转换层:conv7_linear_bn_offset
未成功转换层:conv7_linear_bn_variance
未成功转换层:conv8_expand_bn_offset
未成功转换层:conv8_expand_bn_variance
未成功转换层:conv8_depthwise_bn_offset
未成功转换层:conv8_depthwise_bn_variance
未成功转换层:conv8_se_1_offset
未成功转换层:conv8_se_2_weights
未成功转换层:conv8_se_2_offset
未成功转换层:conv8_linear_bn_offset
未成功转换层:conv8_linear_bn_variance
未成功转换层:conv9_expand_bn_offset
未成功转换层:conv9_expand_bn_variance
未成功转换层:conv9_depthwise_bn_offset
未成功转换层:conv9_depthwise_bn_variance
未成功转换层:conv9_se_1_offset
未成功转换层:conv9_se_2_weights
未成功转换层:conv9_se_2_offset
未成功转换层:conv9_linear_bn_offset
未成功转换层:conv9_linear_bn_variance
未成功转换层:conv10_expand_bn_offset
未成功转换层:conv10_expand_bn_variance
未成功转换层:conv10_depthwise_bn_offset
未成功转换层:conv10_depthwise_bn_variance
未成功转换层:conv10_se_1_offset
未成功转换层:conv10_se_2_weights
未成功转换层:conv10_se_2_offset
未成功转换层:conv10_linear_bn_offset
未成功转换层:conv10_linear_bn_variance
未成功转换层:conv11_expand_bn_offset
未成功转换层:conv11_expand_bn_variance
未成功转换层:conv11_depthwise_bn_offset
未成功转换层:conv11_depthwise_bn_variance
未成功转换层:conv11_se_1_offset
未成功转换层:conv11_se_2_weights
未成功转换层:conv11_se_2_offset
未成功转换层:conv11_linear_bn_offset
未成功转换层:conv11_linear_bn_variance
未成功转换层:conv12_expand_bn_offset
未成功转换层:conv12_expand_bn_variance
未成功转换层:conv12_depthwise_bn_offset
未成功转换层:conv12_depthwise_bn_variance
未成功转换层:conv12_se_1_offset
未成功转换层:conv12_se_2_offset
未成功转换层:conv12_linear_bn_offset
未成功转换层:conv12_linear_bn_variance
未成功转换层:conv_last_weights
未成功转换层:conv_last_bn_scale
未成功转换层:conv_last_bn_offset
未成功转换层:conv_last_bn_mean
未成功转换层:conv_last_bn_variance
未成功转换层:lstm_st1_fc1_w
未成功转换层:lstm_st1_fc1_b
未成功转换层:lstm_st1_out1_w
未成功转换层:lstm_st1_out1_b
未成功转换层:lstm_st2_fc1_w
未成功转换层:lstm_st2_fc1_b
未成功转换层:lstm_st2_out1_w
未成功转换层:lstm_st2_out1_b
未成功转换层:lstm_st1_fc2_w
未成功转换层:lstm_st1_fc2_b
未成功转换层:lstm_st1_out2_w
未成功转换层:lstm_st1_out2_b
未成功转换层:lstm_st2_fc2_w
未成功转换层:lstm_st2_fc2_b
未成功转换层:lstm_st2_out2_w
未成功转换层:lstm_st2_out2_b
未成功转换层:ctc_fc_w_attr
未成功转换层:ctc_fc_b_attr