X-Git-Url: https://fleuret.org/cgi-bin/gitweb/gitweb.cgi?a=blobdiff_plain;f=world.py;h=12c65535ff493700429167132494c5befc05be7e;hb=5366dfd7bd57ec3298d1030f7d5327ff26bc5aad;hp=b35a08ef9a2a149b7820288273bde973aa68fe55;hpb=0f580d4facb4b4b485d0a38d62d06c0639715b77;p=picoclvr.git diff --git a/world.py b/world.py index b35a08e..12c6553 100755 --- a/world.py +++ b/world.py @@ -96,8 +96,6 @@ def train_encoder( logger=None, device=torch.device("cpu"), ): - if logger is None: - logger = lambda s: print(s) mu, std = train_input.float().mean(), train_input.float().std() @@ -157,7 +155,7 @@ def train_encoder( nb_parameters = sum(p.numel() for p in model.parameters()) - logger(f"nb_parameters {nb_parameters}") + logger(f"vqae nb_parameters {nb_parameters}") model.to(device) @@ -209,7 +207,7 @@ def train_encoder( train_loss = acc_train_loss / train_input.size(0) test_loss = acc_test_loss / test_input.size(0) - logger(f"train_ae {k} lr {lr} train_loss {train_loss} test_loss {test_loss}") + logger(f"vqae train {k} lr {lr} train_loss {train_loss} test_loss {test_loss}") sys.stdout.flush() return encoder, quantizer, decoder @@ -378,6 +376,9 @@ def create_data_and_processors( if mode == "first_last": steps = [True] + [False] * (nb_steps + 1) + [True] + if logger is None: + logger = lambda s: print(s) + train_input, train_actions = generate_episodes(nb_train_samples, steps) train_input, train_actions = train_input.to(device_storage), train_actions.to( device_storage @@ -405,6 +406,8 @@ def create_data_and_processors( pow2 = (2 ** torch.arange(z.size(1), device=device))[None, None, :] z_h, z_w = z.size(2), z.size(3) + logger(f"vqae input {train_input[0].size()} output {z[0].size()}") + def frame2seq(input, batch_size=25): seq = [] p = pow2.to(device)