maxim5 / hyper-engine

Python library for Bayesian hyper-parameters optimization
https://pypi.python.org/pypi/hyperengine
Apache License 2.0
86 stars 22 forks source link

Using fine tuned CNN model from example without hyper-engine #4

Open AlexanderFreeman opened 6 years ago

AlexanderFreeman commented 6 years ago

Hello! First of all, thank you for your work, it is really helpful! I am experimenting with code from 1_3_saving_best_models_mnist.py . Tell me, please, how can I use fine-tuned models directly from Tensorflow? I am asking, because I don't see any Tensorflow variable declaration in this code. How to do that easily?

maxim5 commented 6 years ago

@AlexanderFreeman

Yeah, this case isn't covered by current examples. What model do you use? And what TF API?

By the way, you don't see any variables because they're hidden in tf.layer functions. Take a look what tf.layer.dense does.

AlexanderFreeman commented 6 years ago

Thanks, I understand. So, how I can to extract these hidden variables to graph and use the model with session.run() ? I use your model from example 1_3_saving_best_models_mnist.py and I obtained good hyper parameters (better than in my models). Now I only want load saved model and give it some data (and get prediction, of course). Standart methods of doing this necessarily require the declaration of all variables in the graph (maybe I don't know any other methods). I use original Tensorflow on GPU (tensorflow-gpu package).

maxim5 commented 6 years ago

Unfortunately, it doesn't work that easily. You can load a model which graph matches exactly to the defined graph. For example, if you use TF slim API, you can load a pre-trained Inception network that had been trained with inception() from slim API. Loading Inception that had been defined in pure tensorflow will likely result in error, because tensor names are different.

Of course, it's possible to load a model without defining any graph. But I'm not sure what hyper-params you wish to tune then...