add inverse in weight.py