The error is raised, since you are not calling the model.state_dict() method.
That being said, a direct assignment will most likely not work and you could use:
sd = model.state_dict()
sd[key] = layerWeight
model.load_state_dict(sd)

instead.