That's right I misinterpreted the set_weights function's code. I thought that it is just initializing values the of the global variable to the given parameter values.