only finetune last fc layer and other layers fixed
Created by: luweishuang
for leak of enough training data, I want to only finetune last fc layer params and other layers keep fixed by pretrained model. I do this by setting some layers in network.py, like this
param_attr = paddle.attr.ParameterAttribute(is_static=True)
def conv_bn_layer(input, filter_size, num_channels_in, num_channels_out, stride,
padding, act, index_range_data):
conv_layer = paddle.layer.img_conv(
input=input,
filter_size=filter_size,
num_channels=num_channels_in,
num_filters=num_channels_out,
stride=stride,
padding=padding,
act=paddle.activation.Linear(),
bias_attr=False,
param_attr=param_attr)
batch_norm = paddle.layer.batch_norm(input=conv_layer, act=act)
# reset padding part to 0
scale_sub_region = paddle.layer.scale_sub_region(batch_norm, index_range_data, value=0.0)
return scale_sub_region
but when I run "sh run_train.sh", I get the error remove the is_static, the code will run successfully