File tree Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -30,14 +30,19 @@ class Trial(_base_types.Record):
3030 my_experiment = experiment.Experiment.create(experiment_name='AutoML')
3131 my_trial = trial.Trial.create('AutoML')
3232
33- my_tracker = tracker.Tracker.create()
34- # log hyper parameter of learning rate
35- my_tracker.log_parameter('learning_rate', 0.01)
36- my_trial.add_trial_component(my_tracker )
33+ # use `with` statement to ensure `my_tracker.close()` is called
34+ with tracker.Tracker.create() as my_tracker:
35+ # log hyper parameter of learning rate
36+ my_tracker.log_parameter('learning_rate', 0.01 )
3737
38+ # associate the trial component with the trial
39+ my_trial.add_trial_component(my_tracker)
40+
41+ # list trial components within a trial
3842 for trial_component in my_trial.list_trial_components():
3943 print(trial_component)
4044
45+ # cleanup trial
4146 my_trial.remove_trial_component(my_tracker)
4247 my_trial.delete()
4348
You can’t perform that action at this time.
0 commit comments