How to create forward functions for 6 targets

How can I place in 6 targets into the forward function?, and how does that look like….
Then talking about the loss function should I add all the losses to get the final loss?

Hi @Rexedoziem,

Can you please elaborate more on placing 6 targets inside the forward function?

Maybe by means of some pseudo code, please demonstrate what exactly you are trying to achieve and what’s the form of data (inputs and outputs) you have at hand.

Like this is a multioutput classification problem and it has 6 targets variables and I need to put it inside the forward function when working with my model, but I don’t know how to do that?

So, you could return the predictions corresponding to the 6 target variables from the forward function.

And in the training loop, use these 6 predictions and corresponding 6 ground truth to calculate the average loss. (Averaged over all 6 values as well the mini batch)

def forward(self, x):
# Do your stuff here

x1 = F.log_softmax(x) # class probabilities
x2 = … # bounding box calculation
return x1, x2, x3, x4……

Can I do this for the 6 targets? By placing it up to x6?

Yes, you should be fine returning 6 values x1 through x6 as a tuple.

Thanks, but still have a question?

Sure, you can put your relevant doubts here. The community is here to help.

Alright.

using KFolds cross validation, since the target is 6 variables, can we put the 6 targets inside a list and get the values of it? e.g

targets_list = [‘cohesion’, ‘syntax’, ‘vocabulary’, ‘grammar’………]
X = df.targets_list.values.

This is a screenshot