Answers.Body: <p>It is not unheard of to share network weights with multiple output layers. I have seen it on DeepMind's <a href="http://proceedings.mlr.press/v48/mniha16.pdf" rel="nofollow noreferrer">Asynchronous Deep Learning</a> paper, and I have also used it <a href="https://www.dropbox.com/s/ssq2hqoihcks74h/17%20ROBOT.pdf?dl=0" rel="nofollow noreferrer">here</a>.</p>
  <p>The idea is to share all the layers and just have multiple outputs. However, this might decrease the accuracy of your networks, as is the usual performance VS accuracy trade-off.</p>
  <p><a href="https://i.sstatic.net/Y6oCD.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/Y6oCD.png" alt="enter image description here" /></a></p>
  <p>To optimize this, just calculate the loss of both outputs and sum them when feeding the optimizer, like this</p>
  <pre><code>self.target_policy_fast_t = tf.placeholder('float32', [None, a_size], name='target_policy_fast_t')
  self.loss_policy_fast = tf.reduce_mean(tf.nn.softmax_cross_entropy_with_logits(logits=self.network.policy_fast_before_softmax, labels=self.loss_policy_fast_t))
  
  self.target_policy_slow_t = tf.placeholder('float32', [None, a_size], name='target_policy_slow_t')
  self.loss_policy_slow = tf.reduce_mean(tf.nn.softmax_cross_entropy_with_logits(logits=self.network.policy_slow_before_softmax, labels=self.target_policy_slow_t))
  
  self.loss = tf.reduce_mean(self.loss_policy_fast + self.loss_policy_slow, name='loss')
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-07-12T14:33:37.210Z
Answers.Text: That's great thank you! Will this mean my training time will increment exponentially per extra hidden layer in order to get the same accuracy? Also please notify me when you are free to share your paper.
Answers.UserDisplayName: dennis
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-07-12T15:04:13.110Z
Answers.Text: The training time has some correlation with the amount of hidden layers and the complexity of the network, but it depends on hardware and several other factors. With libraries like TensorFlow, up to a certain complexity, my laptop takes the same amount of time to learn networks with different architectures. I will update the answer when I can, but it might take a few months.
Answers.UserDisplayName: BlueMoon93
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-12-05T17:34:20.733Z
Answers.Text: Updated the answer with a link to my paper.
Answers.UserDisplayName: BlueMoon93
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2017-07-12T14:20:55.030Z
Answers.LastActivityDate: 2022-01-05T10:35:12.947Z
Answers.LastEditDate: 2022-01-05T10:35:12.947Z
Answers.UserDisplayName: BlueMoon93
Body: <p>I am currently in the pre-process of starting an image classification and extraction project which needs to output multiple softmax and absolute values from a single image like such:</p>
  
  <pre><code>{
   time: "20:20", 
   teams: [
     {
       red: { goals: 2},
       blue: { goals: 1},
     },
     {
       scored_by : [{
        john: 80%, 
        kyle: 51%, 
        darren: 20%
       }
     ]}
   ]
  }
  </code></pre>
  
  <p>I can create multiple models which are responsible for different task such as reading the time from the image as well as the score and eventually combine both. I would however like to make sure I maximize on efficiency to make sure the process is as fast as possible.</p>
  
  <p>Any pointers in the right direction would be greatly appreciated.</p>
  
  <p>With kind regards,
  Dennis</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-07-12T13:54:20.220Z
Comments.Text: What direction are you talking about, though? Libraries? Architecture of the solution?
Comments.UserDisplayName: BlueMoon93
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-07-12T14:12:41.303Z
Comments.Text: Any library, discussion or (code) demo where multiple outputs are extracted without having to chain different neural nets.
Comments.UserDisplayName: dennis
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-07-12T14:13:32.463Z
Comments.Text: I see what you mean. You should add neural networks to your tags, and remove linear regression then.
Comments.UserDisplayName: BlueMoon93
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-01-05T10:37:23.933Z
Comments.Text: I don't see any question being asked here. "Any pointers in the right direction would be greatly appreciated." is not a question and it's very vague. So, I closed this post as "needs more details". Feel free to edit your post to fix this issue.
Comments.UserDisplayName: nbro
Tags: <neural-networks><machine-learning><classification>
Title: Extracting multiple softmax values from image
UserDisplayName: dennis
ThreadText: # Extracting multiple softmax values from image
  
  (Asked by: username_0 on 2017-07-12)
  
  I am currently in the pre-process of starting an image classification and extraction project which needs to output multiple softmax and absolute values from a single image like such:
  
  ```
  {
   time: "20:20", 
   teams: [
     {
       red: { goals: 2},
       blue: { goals: 1},
     },
     {
       scored_by : [{
        john: 80%, 
        kyle: 51%, 
        darren: 20%
       }
     ]}
   ]
  }
  
  ```
  
  I can create multiple models which are responsible for different task such as reading the time from the image as well as the score and eventually combine both. I would however like to make sure I maximize on efficiency to make sure the process is as fast as possible.
  
  Any pointers in the right direction would be greatly appreciated.
  
  With kind regards,
  username_0
  
  **Tags:** neural-networks, machine-learning, classification
  
  > **Comments:**
  > **username_1**: What direction are you talking about, though? Libraries? Architecture of the solution?  
  > **username_0**: Any library, discussion or (code) demo where multiple outputs are extracted without having to chain different neural nets.  
  > **username_1**: I see what you mean. You should add neural networks to your tags, and remove linear regression then.  
  > **username_2**: I don't see any question being asked here. "Any pointers in the right direction would be greatly appreciated." is not a question and it's very vague. So, I closed this post as "needs more details". Feel free to edit your post to fix this issue.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2017-07-12. Score: 2
  
  It is not unheard of to share network weights with multiple output layers. I have seen it on DeepMind's [Asynchronous Deep Learning](http://proceedings.mlr.press/v48/mniha16.pdf) paper, and I have also used it [here](https://www.dropbox.com/s/ssq2hqoihcks74h/17%20ROBOT.pdf?dl=0).
  
  The idea is to share all the layers and just have multiple outputs. However, this might decrease the accuracy of your networks, as is the usual performance VS accuracy trade-off.
  
  [![enter image description here](https://i.sstatic.net/Y6oCD.png)](https://i.sstatic.net/Y6oCD.png)
  
  To optimize this, just calculate the loss of both outputs and sum them when feeding the optimizer, like this
  
  ```
  self.target_policy_fast_t = tf.placeholder('float32', [None, a_size], name='target_policy_fast_t')
  self.loss_policy_fast = tf.reduce_mean(tf.nn.softmax_cross_entropy_with_logits(logits=self.network.policy_fast_before_softmax, labels=self.loss_policy_fast_t))
  
  self.target_policy_slow_t = tf.placeholder('float32', [None, a_size], name='target_policy_slow_t')
  self.loss_policy_slow = tf.reduce_mean(tf.nn.softmax_cross_entropy_with_logits(logits=self.network.policy_slow_before_softmax, labels=self.target_policy_slow_t))
  
  self.loss = tf.reduce_mean(self.loss_policy_fast + self.loss_policy_slow, name='loss')
  
  ```
  
  > **Comments:**
  > **username_0**: That's great thank you! Will this mean my training time will increment exponentially per extra hidden layer in order to get the same accuracy? Also please notify me when you are free to share your paper.  
  > **username_1**: The training time has some correlation with the amount of hidden layers and the complexity of the network, but it depends on hardware and several other factors. With libraries like TensorFlow, up to a certain complexity, my laptop takes the same amount of time to learn networks with different architectures. I will update the answer when I can, but it might take a few months.  
  > **username_1**: Updated the answer with a link to my paper.  
  
  ---
  
  