pluskid / Mocha.jl

Deep Learning framework for Julia
Other
1.29k stars 254 forks source link

How can I implement a network with multiple datalayers in Mocha? #204

Closed AStupidBear closed 8 years ago

AStupidBear commented 8 years ago

Here is a toy model of my project. Since there's no such a kind of examples in Mocha, I don't know how to deal with the input data. net

greenflash1357 commented 8 years ago

You can easily reuse the same data layer as bottom for two different layers. Simply put bottoms=[:data] in the definitions of your d1 and d2 layers.

As introduction to layer construction, have a look at the MNIST example, (source).

AStupidBear commented 8 years ago

Thanks for your response. However, in my problem d1 and d1 are different data layers using different data.

greenflash1357 commented 8 years ago

I see. The updated sketch explains your problem much better. For final clarification: Do you want ip1 to be a bottom of ip2? Or do you want ip1 and ip2 to share parameters?

AStupidBear commented 8 years ago

@greenflash1357 ip1 is a bottom of ip2

AStupidBear commented 8 years ago

@pluskid @greenflash1357 Could Mocha do this?

greenflash1357 commented 8 years ago

From what I know, Mocha can do this. Two notable things:

  1. Output blob of ip1 and output blob of d2 should share feature dimensions. If they do, ip2 can combine the two bottoms.
  2. You might need a Split Layer, so that Mocha can handle the back propagation from l1 and l2 to ip1.
AStupidBear commented 8 years ago

How can I deal with :data? I haven't seen an example that use :data2Sent from my Huawei Mobile

greenflash1357 commented 8 years ago

Depending on the source of your data, you can either create one data layer with two tops or vice versa.

If you have HDF5 files, the tops of the data layer are the names of the HDF5 datasets as Symbols. If you have a MemoryDataLayer the tops can be arbitrary symbols.

Please provide us with more detailed information if you have further questions.

AStupidBear commented 8 years ago

@greenflash1357 Thank you. I'll try.

greenflash1357 commented 8 years ago

Try a Concat Layer to combine the output of ip1 and d2.

AStupidBear commented 8 years ago

Sorry, I missed Concat LayerSent from my Huawei Mobile

AStupidBear commented 8 years ago

@greenflash1357 It finally works. Thank you!