Use vector for the weights.
Actually, I think the weights after the deserialization should be double.