I am referring to this study https://proceedings.neurips.cc/paper/2020/file/288cd2567953f06e460a33951f55daaf-Paper.pdf entitled "On Warm-Starting Neural Network Training". Here, the authors propose a technique to take a pretrained model and shrink its weights by multiplying the weights by 0.5 and then add a Gaussian noise with sigma of 0.01. I am trying to achieve this using a Keras custom function.
def shrink_perturb(model, lamda=0.5,sigma=0.01):
model.get_weights()
#multiply model weights by 0.5, add gaussian noise with sigma = 0.01
new_model =
return new_model
#apply to a pretrained model
model = load_model('weights/model.h5')
shrunk_model = shrink_perturb(model,lamda=0.5,sigma=0.01)
shrunk_model.summary()
I need support in completing the custom Keras function. Thanks.