Given the string
optimizer = "tensorflow.train.ProximalAdagradOptimizer"
How can I achieve the following:
import tensorflow
optimizer = tensorflow.train.ProximalAdagradOptimizer()
Context
To add context to my specific use case (to address one of the comments): I'm trying to create a text-based config that describes how my model (specifically: estimator) was configured. That way I can easily re-instantiate them after training if I want to train it more or do other stuff with them. I haven't found a simple way to do this; I'm not looking for a saved_model for this. My use case is to easily reload models prior to committing them to a saved_model state. The config would look something like this:
model_config = {
"type": "DNNClassifier",
"n_classes": 10,
"feature_columns": [
{
"numeric_column": [
{
"key": "x"
},
{
"key": "y"
}
]
}
],
"optimizer": {
"AdamOptimizer": {
"learning_rate": 1.0
}
}
}
Given that "config" I can instantiate my estimator with:
estimator = load_estimator(model_config, model_dir=model_dir)
The value of type would resolve to tensorflow.estimator.DNNClassifier. The value of feature_column[0].<key> would resolve to tensorflow.feature_column.numeric_column. Finally, the value of optimizer.<key> would resolve to tensorflow.train.AdamOptimizer.
optimizer = tensorflow.train.ProximalAdagradOptimizerwithout()and later you can executeoptimizer().