# load the final model #-------------------------------------------------------------------------- last_model_file = args.model_folder + '/' + args.prefix + str(args.max_epoch) + args.suffix net = model_loader.load(args.dataset, args.model, last_model_file) w = net_plotter.get_weights(net) s = net.state_dict() #-------------------------------------------------------------------------- # collect models to be projected #-------------------------------------------------------------------------- model_files = [] for epoch in range(args.start_epoch, args.max_epoch + args.save_epoch, args.save_epoch): model_file = args.model_folder + '/' + args.prefix + str(epoch) + args.suffix assert os.path.exists(model_file), 'model %s does not exist' % model_file model_files.append(model_file) #-------------------------------------------------------------------------- # load or create projection directions #-------------------------------------------------------------------------- if args.dir_file: dir_file = args.dir_file else: dir_file = setup_PCA_directions(args, model_files, w, s) #-------------------------------------------------------------------------- # projection trajectory to given directions #-------------------------------------------------------------------------- proj_file = project_trajectory(dir_file, w, s, args.dataset, args.model, model_files, args.dir_type, 'cos') plot_2D.plot_trajectory(proj_file, dir_file)