I have to implement a Convolutional Neural Network, that takes a kinect image (1640480) and return a 1 x8 tensor predicting the class to which the object belongs and a 1 x 4 tensor, predicting the bounding box around the image, if its present.
Please help me how can I implement a suitable model to give two outputs and how to calculate loss and backpropagate in that case?
Also, i have just around 6000 training images, how can I achieve the best possible results with limited number of training images??
Some examples of such projects would be highly helpful.
Hi, Smth
Actually , I still dont understand your idea about tag folks, does it mean the forward function from ptrblcks example sets tow return value or his loss function uses tow loss addition ? can you explain it in detail ? can you give a example code ?
Thank you very much
Hey,
I was going through the keras documentation https://keras.io/getting-started/functional-api-guide/#multi-input-and-multi-output-models
As you can see this is an example of multi-output multi input model.The thing in this example is that the auxiliary output has a loss function .This output is then further used in the model to compute the main_output.
How can I implement some thing like this in Pytorch
Oh okay .Thanks a lot.
Can I also use two different loss functions one on auxiliary_output and one on main_output as shown in the keras link and then add them in the end.
I would like to do the same, but accumulate loss in a loop as my model’s forward function returns a list of outputs.
My question is, how do I initialize the “loss” variable so that I can accumulate in a loop?
Little confused about the accumulation “+”:
So when I write loss = loss1 + loss2, the network knows that I want loss1 to backpropagate through output1, and loss2 to go thru output2, the sequence matters, am I right?
The addition is treated as any other operation in your model, so Autograd will calculate the gradients based on the derivative of the loss accumulation.
If the outputs are independent, your assumption is correct.
hey , i have a problem with “Assertion `cur_target >= 0 && cur_target < n_classes’ failed. at /pytorch/aten/src/THNN/generic/ClassNLLCriterion.c:97” which is still persisting even i tried many solutions found on internet.
Could you print the target values of your current batch inside the training loop and check, if they are all in the range [0, nb_classes-1]?
If you run the code with num_workers=0, the last printed target should be the one causing this error.