def gameWorker(notUsed): print("Staring gameWorker") ds = [] nn = ChessNet() nn.load_state_dict(torch.load("./genDataModel.pt")) print("Loaded nn") cg = ChessGame(nn, nn) examples = cg.gameLoop() ds += examples[0] ds += examples[1] return ds
## loading a previously saved model # path = 'currentNN.pth' # whatever the current best model is saved as # torch.save(model.state_dict(), path) # model = ChessNet() # model.load_state_dict(torch.load(path)) # model.eval() # make sure model doesn't change model = ChessNet() game = ChessGame(model, model) playGame = False if playGame: data = game.gameLoop() print('data collected') dataset = [] dataset += data[0] dataset += data[1] with open("test.txt", "wb") as fp: pickle.dump(dataset, fp) else: with open("test.txt", "rb") as fp: dataset = pickle.load(fp) #Convert model to cuda if the device is cuda. device = torch.device("cuda" if torch.cuda.is_available() else "cpu")