`ScalarizedObjective` serialization and storage
See original GitHub issueHello,
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.
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
OutputSerialization - Amazon Simple Storage Service
Describes the serialization of CSV-encoded Select results. Type: CSVOutput data type. Required: No. JSON. Specifies JSON as request's output serialization ...
Read more >Source code for ax.storage.json_store.encoders
Source code for ax.storage.json_store.encoders ... Objective, ScalarizedObjective from ax.core.optimization_config import ( MultiObjectiveOptimizationConfig ...
Read more >Serialization (C#) | Microsoft Learn
Serialization converts an object into a stream of bytes to store the object or transmit it to memory, a database, or a file....
Read more >Tuning - Spark 2.2.3 Documentation - Apache Spark
Java serialization: By default, Spark serializes objects using Java's ObjectOutputStream ... In Spark, execution and storage share a unified region (M).
Read more >Serialization in Java - DigitalOcean
Serialization in Java allows us to convert an Object to stream that we can send over the network or save it as file...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi @BCJuan, storing scalarized objective has just been added (commit: 933bf4f44dd9287f8a8f6bbff182258bbd2f3499, branch: master, date: March 10th, 2020). Feel free to test it and let us know if there are more issues!
Good catch, let me add support for that.