3
$\begingroup$

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, Dennis

$\endgroup$
  • $\begingroup$ What direction are you talking about, though? Libraries? Architecture of the solution? $\endgroup$ – BlueMoon93 Jul 12 '17 at 13:54
  • $\begingroup$ Any library, discussion or (code) demo where multiple outputs are extracted without having to chain different neural nets. $\endgroup$ – dennis Jul 12 '17 at 14:12
  • $\begingroup$ I see what you mean. You should add neural networks to your tags, and remove linear regression then. $\endgroup$ – BlueMoon93 Jul 12 '17 at 14:13
2
$\begingroup$

It is not unheard of to share network weights with multiple output layers. I have seen it on DeepMind's Asynchronous Deep Learning paper, and I have also used it here.

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

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')
$\endgroup$
  • $\begingroup$ 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. $\endgroup$ – dennis Jul 12 '17 at 14:33
  • $\begingroup$ 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. $\endgroup$ – BlueMoon93 Jul 12 '17 at 15:04
  • $\begingroup$ Updated the answer with a link to my paper. $\endgroup$ – BlueMoon93 Dec 5 '17 at 17:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.