Tensorflow Network input and output node names - tensorflow

I created a CNN model for image classification, the input is an image with the shape of (150,150,3), and the output is a classification name. I put the model in the tensorboard to view the input and output nodes' names.
First, the structure is messy for a sequential network.
From the model description, the input node name is called IteratorGetNext, and there are 5 outputs: [categorical_crossentropy,gradient_tape,Adam,ArgMax_1] and control dependencies.
Here is a screenshot of the structure and input/output description: tensorboard
So I am really confused about the input and output nodes' names.

Related

Output vector given an image for Siamese model

This page (https://keras.io/examples/mnist_siamese/) highlights how we train a Siamese model. The model will output a score given two images input. What I want to do is that, during inference, given an image, I want it to return a 128-dimension vector that represents the image, how should I achieve that?
If you run model.summary() you will see a summary of all model layers. In your case 'model' appears to be the layer of interest. Then you can select the layer that contains the 128D output using the get_layer() method. Finally you can extract the output as below.
model.get_layer('model').output

How to feed input into one layer in a tensorflow pre-trained model?

The pretrained model has many layers, I want to feed my input directly into one intermediate layer (and discard the result of the previous layers).
I only got the .pb file and the ckpt files of that model, so how to modify the computation flow without the source code?
This is the only code file that I got, but I dont know how to use it. Is the graph generate by this file?(much different from the normal tensorflow files)https://github.com/tensorflow/models/blob/master/research/object_detection/models/ssd_mobilenet_v2_feature_extractor.py
Here is what you need to do :
Load the model
Find the name of the layer or retrieve the tensor of the layer you want to feed values to (let's name it 'Z' for the sake of the explanation)
Find the name of the layer or retrieve the tensor of the layer you want to get results from ('Y')
Run this code snippet :results = sess.run('Y:0', {'Z:0': your_value})

What are input and output node names in inception v3 with slim library?

I retrained inceptionV3 model on my own data using Tensorflow slim. Below files are generated after training :-
graph.pbtxt, model.ckpt, model.meta, model.index, checkpoint,
events.out.tfevents
I want to freeze the graph files and create a .pb file. I don't know what is input node and output node in inception v3. And using Tensorboard is complex for me.
What are the input/output nodes in inceptionV3?(in slim/nets) OR how can I find the input/output nodes ?
OS : window 7
(A). If you will make it to bottom of this link. You would find this somewhere(specific to inceptionV3) :
input_layer=input
output_layer=InceptionV3/Predictions/Reshape_1
(B). Another way is to print all tensors of the model and get input/output tensor
from tensorflow.python.tools.inspect_checkpoint import print_tensors_in_checkpoint_file
ckpt_path="model.ckpt"
print_tensors_in_checkpoint_file(file_name=ckpt_path, tensor_name='', all_tensors=True, all_tensor_names=True)
(C). If you need to print tensor names of .pb file. You can use this simple code.
Check what would work for you.

Changing Inception-v4 architecture to do Multi-label classification in Tensorflow

I am working on image tagging and annotation problem, simply an image may contain multiple objects. I want to train inception-v4 for multi-label classification. My training data will be an image and a vector of length equals the number of classes and has 1 in each index if the object exists in the image. For example, If I have four classes (Person, car, tree, buildings). If an image contains a person and car. Then my vector will be (1, 1, 0, 0).
What changes do I need to make to train inception-v4 for the tagging and annotation problem?
Do I only need to change the input format and change the loss function from softmax to sigmoid_cross_entropy_with_logits in the inception-v4 architecture?
https://github.com/tensorflow/models/blob/master/slim/nets/inception_v4.py
Thank you in advance.
If you'd like to retrain a model to output different labels, check out the image_retraining example: https://github.com/tensorflow/tensorflow/blob/r1.1/tensorflow/examples/image_retraining/retrain.py
In that example, we retrain the standard inception v3 model to recognize flowers instead of the standard ImageNet categories.

making a pre-trained mxnet network fully convolutional

I wish to convert one of the existing pre-trained mxnet models available here to a fully convolutional one.
This means being able to input an image of any size, specifying the stride, and getting a full output.
For instance, assume the model was trained on 224x224x3 images. I want to input an image which is 226x226x3 and specify stride=1, in order to get a 3x3xnum-classes output.
I'm not asking "theoretically", but rather for an example code :-)
Thanks!
According to this example: https://github.com/dmlc/mxnet-notebooks/blob/master/python/tutorials/predict_imagenet.ipynb
You can change the data shape when binding the model:
mod.bind(for_training=False, data_shapes=[('data', (1,3,226,226))])
Then you can input an 3 * 226 * 226 image.
Another example:http://mxnet.io/how_to/finetune.html
This example replaces the last layer of pre-trained model with a fc layer.