Skip to content
ml-recall

#non-scalar-backward

1 question from PyTorch

Timed test

1 question · 1 min · score and explanations at the end

Take a test
Q 1 / 1Score 0 / 0

Question 1: Single choice

hardAI-checkedPyTorch

f doubles its input until the norm reaches 1000 and multiplies by 100 if the sum is not positive. Now a is a vector:

def f(a):
    b = a * 2
    while b.norm() < 1000:
        b = b * 2
    if b.sum() > 0:
        c = b
    else:
        c = 100 * b
    return c

a = torch.randn(3, requires_grad=True)
d = f(a)

Which statement is correct?

Choose one option