projects
/
beaver.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Update
[beaver.git]
/
beaver.py
diff --git
a/beaver.py
b/beaver.py
index
6ed9dd2
..
5abe39b
100755
(executable)
--- a/
beaver.py
+++ b/
beaver.py
@@
-127,6
+127,8
@@
def log_string(s):
sys.stdout.flush()
sys.stdout.flush()
+log_string(f"cmd {' '.join(sys.argv)}")
+
for n in vars(args):
log_string(f"args.{n} {getattr(args, n)}")
for n in vars(args):
log_string(f"args.{n} {getattr(args, n)}")
@@
-236,8
+238,13
@@
def oneshot_trace_loss(mazes, output, policies, height, width):
def oneshot(model, learning_rate_scheduler, task):
t = model.training
model.eval()
def oneshot(model, learning_rate_scheduler, task):
t = model.training
model.eval()
- mazes = task.test_input[:
32
].clone()
+ mazes = task.test_input[:
48
].clone()
mazes[:, task.height * task.width :] = 0
mazes[:, task.height * task.width :] = 0
+ policies = task.test_policies[:48]
+ targets = maze.stationary_densities(
+ mazes[:, : task.height * task.width].view(-1, task.height, task.width),
+ policies.view(-1, 4, task.height, task.width),
+ ).flatten(-2)
output = eval_mygpt(model, mazes, prompt_len=task.height * task.width)
output = F.softmax(output, dim=2)
print(f"{output.size()=}")
output = eval_mygpt(model, mazes, prompt_len=task.height * task.width)
output = F.softmax(output, dim=2)
print(f"{output.size()=}")
@@
-245,13
+252,17
@@
def oneshot(model, learning_rate_scheduler, task):
-1, task.height, task.width
)
mazes = mazes[:, : task.height * task.width].reshape(-1, task.height, task.width)
-1, task.height, task.width
)
mazes = mazes[:, : task.height * task.width].reshape(-1, task.height, task.width)
- # targets = targets.reshape(-1, task.height, task.width)
+ targets = targets.reshape(-1, task.height, task.width)
+ paths = task.test_input[:48, task.height * task.width :].reshape(
+ -1, task.height, task.width
+ )
filename = f"oneshot.png"
maze.save_image(
os.path.join(args.result_dir, filename),
mazes=mazes,
filename = f"oneshot.png"
maze.save_image(
os.path.join(args.result_dir, filename),
mazes=mazes,
+ # target_paths=paths,
score_paths=proba_path,
score_paths=proba_path,
-
#
score_truth=targets,
+ score_truth=targets,
)
log_string(f"wrote {filename}")
)
log_string(f"wrote {filename}")
@@
-324,8
+335,8
@@
def oneshot_old(gpt, learning_rate_scheduler, task):
)
# -------------------
)
# -------------------
- mazes = task.test_input[:
32
, : task.height * task.width]
- policies = task.test_policies[:
32
]
+ mazes = task.test_input[:
48
, : task.height * task.width]
+ policies = task.test_policies[:
48
]
output_gpt = eval_mygpt(
gpt, mazes, mode=args.oneshot_input, prompt_len=task.height * task.width
)
output_gpt = eval_mygpt(
gpt, mazes, mode=args.oneshot_input, prompt_len=task.height * task.width
)
@@
-568,7
+579,7
@@
class TaskMaze(Task):
f"accuracy_test nb_total {test_nb_total} nb_correct {test_nb_correct} accuracy {(100.0*test_nb_correct)/test_nb_total:.02f}%"
)
f"accuracy_test nb_total {test_nb_total} nb_correct {test_nb_correct} accuracy {(100.0*test_nb_correct)/test_nb_total:.02f}%"
)
- input = self.test_input[:
32
]
+ input = self.test_input[:
48
]
result = input.clone()
ar_mask = result.new_zeros(result.size())
ar_mask[:, self.height * self.width :] = 1
result = input.clone()
ar_mask = result.new_zeros(result.size())
ar_mask[:, self.height * self.width :] = 1