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):
30
30
my_experiment = experiment.Experiment.create(experiment_name='AutoML')
31
31
my_trial = trial.Trial.create('AutoML')
32
32
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 )
37
37
38
+ # associate the trial component with the trial
39
+ my_trial.add_trial_component(my_tracker)
40
+
41
+ # list trial components within a trial
38
42
for trial_component in my_trial.list_trial_components():
39
43
print(trial_component)
40
44
45
+ # cleanup trial
41
46
my_trial.remove_trial_component(my_tracker)
42
47
my_trial.delete()
43
48
You can’t perform that action at this time.
0 commit comments