Skip to content
ml-recall

#side-effects

1 question from Deep Learning Frameworks

Timed test

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

Take a test
Q 1 / 1Score 0 / 0

Question 1: Short answer

hardAI-checkedDeep Learning Frameworks
import jax
import jax.numpy as jnp

calls = []

@jax.jit
def f(x):
    calls.append(1)        # a Python side effect
    return 2 * x

for v in [1.0, 2.0, 3.0]:
    f(jnp.array(v))
f(jnp.arange(3.0))
f(jnp.arange(4.0))
f(jnp.arange(4.0) + 1)
print(len(calls))

What does the last line print?

a whole number