I have an ONNX model and I want to debug the intermediate layer outputs and inputs of the model. How can this be done ?
Related
I am trying to do fine-grained image classification for CUB-200-2011 dataset, couldn't figure out the correct way for loading the data. I'm using pre-trained ImageNet ResNet-101 for training by freezing all layers except last two layers. Suggest a way to for data loading in Pytorch.
I have two models that are in ONNX format. Both models are similar (both are pre-trained deep learning models, ex. ResNet50 models). The only difference between them is that the last layers are optimized/retrained for different data sets.
I want to merge the first k layers of these two models, as shown below. This should enhance the performance of inference.
To make my case clearer these are examples from other machine learning tools to implement this feature Ex. Pytorch, Keras.
You can use the ONNX package and the APIs it exposes (https://github.com/onnx/onnx/blob/master/docs/PythonAPIOverview.md) to mutate models/graphs.
The sclblonnx package provides a number of higher level functions to edit ONNX graphs, including the ability to merge two subgraphs.
sclblonnx package does not support dynamic size inputs.
For dynamic size inputs, one solution would be writing your own code using ONNX API as stated earlier.Another solution would be converting the two ONNX models to a framework(Tensorflow or PyTorch) using tools like onnx-tensorflow or onnx2pytorch. You could manipulate the networks in the Tensorflow or Pytorch and export the whole network to Onnx format.
I am using a pre-trained model which I want to add Elementwise layer that products the output of two layers: one layer is output of convolution layer 1x1x256x256 and the other is also the output of convolution layer 1x32x256x256. My question is: If we add elementwise layer for multiplying two layers and sending to the next layer, should we train from the scratch because the architecture is modified or still it is possible to use the pretrained model?
Thanks
Indeed making architectural changes puts the learned features at odds.
However, there's no reason not to use the learned weight for layers below the change -- these layers are not affected by the change, so they can benefit from the initialization.
As for the rest of the layers, I suppose init from trained weights should not be worse than random, So why not?
Don't forget to init any new layers with random weights (the default in caffe is zero - and this might cause trouble for learning).
I want to overfit my model on a mini-batch of data, to see if my model is correct. My dataset is in lmdb format. The data layer automatically update when I perform solver.step(). How can I avoid solver from loading new data in Caffe?
I use this with the Pycaffe interface:
if overfit: lmdb_cursor.first()
I have a flag (overfit) that when set calls this method which resets the cursor back to the beginning of the database for each batch. Hope this helps.
I want to learn how to write caffe python layers.
But I only find examples about very simple layers like pyloss.
How to write python caffe with trainable parameters?
For example, how to write a fully connected python layer?
Caffe stores the layer's trainable parameters as a vector of blobs. By default this vector is empty and it is up to you to add parameters blobs to it in the setup of the layer. There is a simple example for a layer with parameters in test_python_layer.py.
See this post for more information about "Python" layers in caffe.