-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Winning without optimization / SFT, by modeling (outcome, moves) pairs #1
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,29 +53,52 @@ def seq_to_board(seq): | |
return board | ||
|
||
|
||
def save_data(trajectories): | ||
w_map = {-1: 0, 1: 1, None: 2} | ||
|
||
def save_data(trajectories, incl_winner=False): | ||
outcomes = defaultdict(int) | ||
for b, s, w in trajectories: | ||
#print(b, s, w) | ||
outcomes[w] += 1 | ||
|
||
print(outcomes) | ||
|
||
data = np.full((len(trajectories), SEQ_LENGTH), PAD, dtype=np.int16) | ||
for i in range(len(trajectories)): | ||
row = [START] + trajectories[i][1] | ||
if i < 10: | ||
print(row) | ||
data[i, : len(row)] = row | ||
if not incl_winner: | ||
data = np.full((len(trajectories), SEQ_LENGTH), PAD, dtype=np.int16) | ||
for i, (b, s, w) in enumerate(trajectories): | ||
# start with the START token, then sequence | ||
row = [START] + s | ||
if i < 10: | ||
print(row) | ||
data[i, : len(row)] = row | ||
else: | ||
data=np.full((len(trajectories), SEQ_LENGTH+1), PAD, dtype=np.int16) | ||
for i, (b, s, w) in enumerate(trajectories): | ||
# start with the START token, then winner, then sequence | ||
row = [START, w_map(w)] + s | ||
if i < 10: | ||
print(row) | ||
data[i, : len(row)] = row | ||
|
||
np.random.shuffle(data) | ||
|
||
np.save("data/train.npy", data) | ||
|
||
|
||
if __name__ == "__main__": | ||
# Use typer instead | ||
import typer | ||
app = typer.Typer() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is app needed here? |
||
|
||
def main(optimal: bool = False, incl_winner: bool = False): | ||
board = np.zeros((3, 3), dtype=int) | ||
# trajectories = all_trajectories(board, [], 1) | ||
if optimal: | ||
trajectories = all_optimal_trajectories(board, [], 1) | ||
else: | ||
trajectories = all_trajectories(board, [], 1) | ||
# trajectories = all_optimal_trajectories(board, [], 1, {-1, 1}) | ||
trajectories = all_optimal_trajectories(board, [], 1) | ||
# trajectories = all_optimal_trajectories(board, [], 1) | ||
print(len(trajectories)) | ||
save_data(trajectories) | ||
save_data(trajectories, incl_winner) | ||
|
||
if __name__ == "__main__": | ||
typer.run(main) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
torch | ||
typer | ||
wandb | ||
chardet | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is chardet used? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was likely just an issue with my conda env; removing that |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should probably use new tokens for these. (declare in tokens.py)