Skip to content
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

How do the outputs change? #23

Open
yarinbar opened this issue Dec 6, 2023 · 0 comments
Open

How do the outputs change? #23

yarinbar opened this issue Dec 6, 2023 · 0 comments

Comments

@yarinbar
Copy link

yarinbar commented Dec 6, 2023

According to the code (and assuming that STEPS = 1, i dont understand how the outputs change after the adaptation:

def forward(self, x):
    if self.episodic:
        self.reset()

    for _ in range(self.steps):
        outputs = forward_and_adapt(x, self.model, self.optimizer)
    return outputs

@torch.enable_grad()  # ensure grads in possible no grad context for testing
def forward_and_adapt(x, model, optimizer):
    """Forward and adapt model on batch of data.

    Measure entropy of the model prediction, take gradients, and update params.
    """
    # forward
    outputs = model(x)
    # adapt
    loss = softmax_entropy(outputs).mean(0)
    loss.backward()
    optimizer.step()
    optimizer.zero_grad()
    return outputs

judging by the code, you return the original outputs however they do change somehow, how?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant