How to import trained DNNClassifier using C_API - tensorflow

I have trained DNNClassifier using Python (conda tensorflow installation). The trained model needs to be used for evaluation using C_API. Is there a way to load both graph and weights of the trained model using C_API?

There is a way to load h5 and any data for C_API. Maybe some googling could help. I've found this article to be helpful.
And for DNNClassifier on C_API I think you should Implement it manually using pure Tensor Array on C_API. cmiimw

Related

Saving the Learned Weights of a Network to Train on another Dataset

I would like to train a MLP(Multi Layer Perceptron) with MNIST dataset. I use a validation set so I can save the weights of the best model. Then I want to load these weights back into the same architecture and use them to initialize and train with another dataset. I would like to know if this is possible with Tensorflow 1.x or 2.x. Right now I am trying to write a custom function to do it but it is getting complicated. I am using tf 1.x.
I suggest you take a look at tensorflow's documentation, here a link of a tutorial to save your weights and load them afterwards:
https://www.tensorflow.org/tutorials/keras/save_and_load

Tensorflow Extended: Is it possible to use pytorch training loop in Tensorflow extended flow

I have trained an image classification model using pytorch.
Now, I want to move it from research to production pipeline.
I am thinking of using TensorFlow extended. I have a very noob doubt that will I'll be able to use my PyTorch trained model in the TensorFlow extended pipeline(I can convert the trained model to ONNX and then to Tensorflow compatible format).
I don't want to rewrite and retrain the training part to TensorFlow as it'll be a great overhead.
Is it possible or Is there any better way to productionize the PyTorch trained models?
You should be able to convert your PyTorch image classification model to Tensorflow format using ONNX, as long as you are using standard layers. I would recommend doing the conversion and then look at both model summaries to make sure they are relatively similar. Also, do some tests to make sure your converted model handles any particular edge cases you have. Once you have confirmed that the converted model works, save your model as a TF SavedModel format and then you should be able to use it in Tensorflow Extended (TFX).
For more info on the conversion process, see this tutorial: https://learnopencv.com/pytorch-to-tensorflow-model-conversion/
You could considering using the torchX library. I haven't use it yet, but it seems to make it easier to deploy models by creating and running model pipelines. I don't think it has the same data validation functionality that Tensorflow Extended has, but maybe that will be added in the future.

How to do fine tuning on TFlite model

I would like to fine tune a model on my own data. However the model is distributed by tflite format. Is there anyway to extract the model architecture and parameters out of the tflite file?
One approach could be to convert the TFLite file to another format, and import into a deep learning framework that supports training.
Something like ONNX, using tflite2onnx, and then import into a framework of your choice. Not all frameworks can import from ONNX (e.g. PyTorch). I believe you can train with ONNXRuntime, and MXNet. Unsure if you can train using TensorFlow.
I'm not sure to understand what you need. But if you want to know the exact architecture of your model you can use neutron to find out.
You will get something like the this :
And for your information TensorFlow Lite is not meant to be finetuned. You need to finetune a classic TensorFlow model and then convert it to TensorFlow Lite.

Dumping Weights in TensorflowLite

new Tensorflow 2.0 user. My project requires me to investigate the weights for the neural network i created in Tensorflow (super simple one). I think I know how to do it in the regular Tensorflow case. Namely I use the command model.save_weights(filename). I would like to repeat this effort for a .tflite model but I am having trouble. Instead of generating my own tensorflow lite model, I am using one of the many models which are provided online: https://www.tensorflow.org/lite/guide/hosted_model to avoid having to troubleshoot my use of the Tensorflow Lite converter. Any thoughts?

Can I run a model trained using tensorflow on mxnet?

I have models trained on tensorflow. Can I use mxnet in forward only mode to run these ?
https://github.com/dmlc/nnvm says this should be possible in future, but is the support available today ?
MXNet doesn't have tensorflow model converter yet. It does have a caffe-to-mxnet converter. So you can convert your tf model to caffe, that would work..
https://github.com/dmlc/mxnet/tree/master/tools/caffe_converter