I am currently training a bidirectional RNN model using the CudnnRNNRelu on tensorflow. I want to use these checkpoints for inference on a CPU machine. The documentation suggests that models trained with Cudnn specific cells (CudnnRNNRelu, CudnnRNNTanh, CudnnLSTM etc ..) cannot be restored directly using platform independent rnn cells ( tf.contrib.rnn.BasicRNNCell etc.. ). While there are separate cells to restore LSTM and GRU cells ( CudnnComaptibleLSTMCell and CudnnCompatibleGRUCell) , there is no indication of how to use CudnnRNNRelu trained checkpoints with platform independent rnn cells.
Restoring works properly on a GPU machine. Is there a way to restore the CudnnRNNRelu checkpoints?
Related
How can I understand which layers are frozen fine-tuning a detection model from Tensorflow Model Zoo 2?
I have already set with success the Path for fine_tune_checkpoint and fine_tune_checkpoint_type: detection and in the file proto I have already read that "detection" means
// 2. "detection": Restores the entire feature extractor.
The only parts of the full detection model that are not restored are the box and class prediction heads.
This option is typically used when you want to use a pre-trained detection model
and train on a new dataset or task which requires different box and class prediction heads.
I didn't really understand what does that means. Restored means Frozen in this context?
As I understand it, currently the Tensorflow 2 Object detection does not freeze any layers when training from a fine tune checkpoint. There is a issue reported here to support specifying which layers to freeze in the pipeline config. If you look at the training step function, you can see that all trainable variables are used when applying gradients during training.
Restored here means that the model weights are copied from the checkpoint to be used as a starting point for training. Frozen would mean that the weights are not changed (i.e. no gradient is applied) during training.
My goal is to optimize a pre-trained model from TFHub for inference. Therefore I would like to use an object detection model with multiple outputs:
https://tfhub.dev/tensorflow/ssd_mobilenet_v2/fpnlite_640x640/1
where the archive contains a SavedModel file
https://tfhub.dev/tensorflow/ssd_mobilenet_v2/fpnlite_640x640/1?tf-hub-format=compressed
I came across the methods optimize_for_inference and freeze_graph, but read on the following thread that is is no longer supported in TF2:
https://stackoverflow.com/a/56384808/11687201
So how is optimization for inference done with TF2?
The plan is to use this one of the pre-trained networks for transfer learning and use this network later on with a hardware accelerator, the converter for this hardware requires a frozen graph as input.
I am importing a pretrained mobilenet's model mobilenet_v1_0.25_128_frozen.pb into my tensorflow environment. Once imported, I want to be able to save a snapshot of the model architecture in the form of .png. I know that there is a way to do this in keras with tf.keras.utils.plot_model(model, to_file="model.png"). Is there a way to do this in tensorflow session without using Tensorboard. In case, you recommend using tensorboard, I don't want to separately run tensorboard. I want a way to save the model architecture inside the tensorflow session without starting tensorboard.
I have a model trained in CUDNNLSTM, how can I use this in CPU? How can we export CUDNNLSTM variables to CPU bases weights so that the trained model can be run on CPU also.
One safe way, that always works, would be to simply save the variables to some file with appropriate format like hdf5 and manually load them again. This way you have complete control over what is happening and don't depend on the system you are using. You can even train a model in TensorFlow, save the variables and load them for use with a different library like PyTorch (assuming you defined the exact same model there).
I wanna use the inception v3 model in tensor flow for feature extraction. But the number of the images I am using is a lot, so it takes long time to run. So, I am going to use GPU. I have installed Cuda 7.5 and cuDnn correctly.
I am using following code in the CPU mode for one image:
with tf.Session as sess:
softmax_tensor =sess.graph.get_tensor_by_name('pool_3:0')
feat_vect = numpy.squeeze(sess.run(softmax_tensor,{'DecodeJpeg:0': in_image}))
So, my question is that how should I change my code so I can use it for many batches by GPU?