Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DAG container #7

Open
ikostrikov opened this issue May 29, 2015 · 5 comments
Open

DAG container #7

ikostrikov opened this issue May 29, 2015 · 5 comments

Comments

@ikostrikov
Copy link
Member

Add a direct acyclic graph container so we could builld a network as in Caffe and Lasagne.

Example:

model = bb8.DAG()

fc1 = model.add('input', bb8.Linear(32, 64))
relu1 = model.add(fc1, bb8.ReLU())

@lucasb-eyer
Copy link
Member

Agreed, and with the current design it should not even be hard to do.

And then we or someone else can build higher level functions to read cuda-convnet/caffe model files and instantiate such a model, but who'd want such a thing, hehe.

@ikostrikov
Copy link
Member Author

We need to discuss how to implement this DAG container. I suggest to keep all symbolic variables hidden and simply work with some unique ids that is generated by the "add" function.

Also I think that we need to handle multiple inputs and multiple outputs for this container.

@lucasb-eyer
Copy link
Member

General

Agreed on hiding all symbolic variables. But I think instead of using automatic unique IDs, we should let the user give unique names to all layers:

model = bb8.DAG()
model.add('input', bb8.Linear(32, 64), 'fc1')
model.add('fc1', bb8.Softmax(), 'sm')

or, with keyword arguments:

model.add(in='fc1', fn=bb8.Softmax(), out='sm')

Multiple inputs

A nice example of using this would be a depth-from-stereo algorithm which needs two pictures as input. With the name giving, this should be relatively easy, something like this would be nice:

model = bb8.DAG()
model.add_input('left image')
model.add_input('right image')
model.add('left image', bb8.Linear(32*32, 64), 'fcL1')
model.add('right image', bb8.Linear(32*32, 64), 'fcR1')
model.add(['fcL1', 'fcL2'], bb8.Mux(), 'mux')
model.add('mux', bb8.Linear(64+64, 10), 'fc2')
model.add('fc2', bb8.Softmax(), 'sm')

Multiple Outputs

A use-case for this (vision again) would be human attributes, e.g. for a picture say whether the person is male/female and also has glasses or not.

For this, we would also need a kind of weighted-sum-of-costs cost, which I think both of us had in our toolboxes. Then, it could simply be that the user calls model.add_output('fc2', bb8.Softmax(), 'sm') instead of model.add(...).

Thoughts?

@lucasb-eyer
Copy link
Member

Addendum: and if we make two additional things:

  1. Make add return the output-name, and
  2. Make the out parameter of add default to None and generate an automatic unique ID if it is None.

Then it is also possible to use it exactly as in your first example. If you agree and want, I can write up a proposal implementation when I get time (maybe this evening).

@ikostrikov
Copy link
Member Author

I agree with your suggestions and with addendum as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants