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

Breakdown if training function #43

Open
praksharma opened this issue Mar 11, 2024 · 0 comments
Open

Breakdown if training function #43

praksharma opened this issue Mar 11, 2024 · 0 comments

Comments

@praksharma
Copy link
Owner

praksharma commented Mar 11, 2024

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()
"""

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