NervanaSystems / neon

Intel® Nervana™ reference deep learning framework committed to best performance on all hardware
http://neon.nervanasys.com/docs/latest
Apache License 2.0
3.87k stars 811 forks source link

Multi task learning use Neon #358

Open tianxiangchen2015 opened 7 years ago

tianxiangchen2015 commented 7 years ago

Hi guys,

How can I use neon to do multi task learning? First, I tired to use layer container to handle multiple inputs and multiple outputs. But the problem is "Arrayiterator" can not handle multiple inputs with multiple number of classes. For example, I have 3 datasets, first and second dataset has 2 classes, the last one has 4 classes. How can I do it?

I want to build a model with 3 inputs and one shared hidden layer, then splits to 3 outputs.

Thanks

hanlint commented 7 years ago

Hello,

You will first want to use the MergeBroadcast container (see examples/image_caption.py for an example where you have two inputs) to build your model. For the data side, you can either write a custom iterator that yields a tuple of inputs. In your case something like:

yield (x1, x2, x3), (y1, y2, y3)

Alternatively, if you pack your data into hdf5 datasets, you may also be able to use the HDF5 iterator, but we haven't really tested this.