add parameter for weight file and correct some bugs