Hello,
Ax version: 0.1.6
I am trying to save an experiment which looks like:
experiment = Experiment(
name="experiment_building_blocks",
search_space=search_space(),
)
optimization_config = OptimizationConfig(
objective=ScalarizedObjective(
metrics=[AccuracyMetric(datasets, dataloaders,
device, datasetsizes,
epochs, name="accuracy"),
WeightMetric(datasets, bits, name="weight")],
weights=[0.5, 0.5],
minimize=True,
),
)
experiment.optimization_config = optimization_config
experiment.runner = MyRunner()
As seen it is an Scalarized Objective with two metrics. When I try to save the experiment by registering both the runner and the metrics:
register_metric(AccuracyMetric)
register_metric(WeightMetric)
register_runner(MyRunner)
save(exp, path.join(root, name))
Then the following error appears:
optimization_config Traceback (most recent call last):
File "main.py", line 172, in <module>
root=parsed.root)
File "main.py", line 113, in main
save_data(exp, name, root)
File "main.py", line 152, in save_data
save(exp, path.join(root, name))
File "/home/kostal/anaconda3/envs/deep/lib/python3.7/site-packages/ax/storage/json_store/save.py", line 22, in save_experiment
json_experiment = object_to_json(experiment)
File "/home/kostal/anaconda3/envs/deep/lib/python3.7/site-packages/ax/storage/json_store/encoder.py", line 74, in object_to_json
print(k, v)
File "/home/kostal/anaconda3/envs/deep/lib/python3.7/site-packages/ax/core/optimization_config.py", line 138, in __repr__
objective=repr(self.objective),
File "/home/kostal/anaconda3/envs/deep/lib/python3.7/site-packages/ax/core/objective.py", line 44, in __repr__
self.metric.name, self.minimize
File "/home/kostal/anaconda3/envs/deep/lib/python3.7/site-packages/ax/core/objective.py", line 84, in metric
raise NotImplementedError("ScalarizedObjective is composed of multiple metrics")
Looks like that in the source of Scalarized Objective it has no __repr__method. I have tried to implement it as:
def __repr__(self) -> str:
base_str = 'Objective('
for k, v in zip(self.metrics, self.weights):
base_str += ' metric_name="{}", metric_weight="{}",'.format(
k.name, v)
base_str += ' minimize={})'.format(self.minimize)
return base_str
With no luck because another appears, as this is not registered as an ENCODER_REGISTRY for JSON encoding.
Thanks in advance.
Hello,
Ax version: 0.1.6
I am trying to save an experiment which looks like:
As seen it is an Scalarized Objective with two metrics. When I try to save the experiment by registering both the runner and the metrics:
Then the following error appears:
Looks like that in the source of Scalarized Objective it has no
__repr__method. I have tried to implement it as:With no luck because another appears, as this is not registered as an ENCODER_REGISTRY for JSON encoding.
Thanks in advance.