You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It involved miltiple decorators. Click edit to see the actual text.
"""python
import functools
import time
def initialise_training(training_function):
@functools.wraps(training_function)
def wrapper_training_init(*args, **kwargs):
# use self to initialise stuff
print("initialisation")
training_function(*args, **kwargs)
return wrapper_training_init
It involved miltiple decorators. Click edit to see the actual text.
"""python
import functools
import time
def initialise_training(training_function):
@functools.wraps(training_function)
def wrapper_training_init(*args, **kwargs):
# use self to initialise stuff
print("initialisation")
training_function(*args, **kwargs)
return wrapper_training_init
def timer(func):
@functools.wraps(func)
def wrapper_timer(*args, **kwargs):
print("timer")
start_time = time.perf_counter()
func(*args, **kwargs) # execute the decorated function
end_time = time.perf_counter()
run_time = end_time - start_time
print(f"Time taken: {func.name!r} in {run_time:.4f} secs")
return wrapper_timer
@initialise_training
@Timer
def train():
print("hello")
train()
"""
The text was updated successfully, but these errors were encountered: