Fix bug in weight value generation.