Is this neural net with two outputs still one neural network?

username: Alio
cooked: <p>I’d like multiple outputs from a neural network from different inputs. I think I might have it below, but I’m not sure it is what I need.<br>
What I need is for “net1” and “net2” to be aware of each other. Is this possible? Is this what is happening? See, I have a system I want a neural network to control. When net2 is taking an input and giving an output I need it to be affected by the training that happened to net1.</p>
<pre><code class="lang-auto">
class Network(nn.Module):
    def __init__(self):
        super().__init__()
        
        self.net1 = nn.Sequential(
            nn.Linear(3, 5),
            nn.ReLU(),
            nn.Linear(5, 80),
            nn.ReLU(),
            nn.Linear(80, 40),
            nn.ReLU(),
            nn.Linear(40, 16),
            nn.ReLU(),
            nn.Linear(16, 2))  
        
        self.net2 = nn.Sequential(
            nn.Linear(3, 5),
            nn.ReLU(),
            nn.Linear(5, 80),
            nn.ReLU(),
            nn.Linear(80, 40),
            nn.ReLU(),
            nn.Linear(40, 16),
            nn.ReLU(),
            nn.Linear(16, 4))
        
    def forward(self, x):
        return self.net1(x), self.net2(x)
</code></pre>

username: ptrblck
cooked: <p>No, <code>net1</code> and <code>net2</code> do not share anything and are independently executed.<br>
Updating or using one model won’t influence the other one in any way.</p>

username: Alio
cooked: <p>What if I want two outputs from one neural network where…<br>
One of the outputs is a bool, in other words, just an argmax from two values,<br>
And the other is a value between 0 and 1000, which will come from an argmax with a thousand values.</p>
<p>Would you just give the neural net an output of 1002? Does this suffice? Does this make sense what I’m asking? Do the 1000 outputs totally outweigh the 2 outputs? Should I make the output for the bool 100 or also 1000 outputs in order to balance the network? To make sure the network knows the bool is just as important as the value between 0 and 1000?<br>
Does the network understand the “weight” of the bool outputs, which are 0.2% of the network?</p>

username: ptrblck
cooked: <aside class="quote no-group" data-username="Alio" data-post="3" data-topic="147305">
<div class="title">
<div class="quote-controls"></div>
<img loading="lazy" alt="" width="24" height="24" src="https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/alio/48/8142_2.png" class="avatar"> Alio:</div>
<blockquote>
<p>One of the outputs is a bool, in other words, just an argmax from two values,<br>
And the other is a value between 0 and 1000, which will come from an argmax with a thousand values.</p>
</blockquote>
</aside>
<p>I assume you want to use <code>argmax</code> to get the predictions but not to calculate the losses, since <code>argmax</code> is not differentiable.</p>
<p>I don’t if creating a single output (assuming from a single model) or different outputs (assuming from different models) would work better. If you are using a single model and the outputs have large differences in their range, I would be concerned about the loss calculation as the larger loss could “mask” the smaller one.</p>