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

Added Net Templates to easy definition of Nets #1518

Closed
wants to merge 8 commits into from

Conversation

sguada
Copy link
Contributor

@sguada sguada commented Dec 2, 2014

This PR is inspired by #1290 and the discussion there. This PR also reuse parts of the code done by @cypof.

Instead of modifying Net.Init() this PR provides a new tool ./build/tools/expand_net that is able to expand templates and do the need string substitutions.
Usage:

expand_net net_proto_file_in net_proto_file_out

For some template examples look at `examples/templates/'

./build/tools/expand_net examples/templates/example_net.template examples/templates/example_net.prototxt

@sguada
Copy link
Contributor Author

sguada commented Dec 2, 2014

@longjon @shelhamer What do you think?

@sguada
Copy link
Contributor Author

sguada commented Dec 3, 2014

@shelhamer @jeffdonahue @longjon do you know how to avoid time-out errors in Travis?
How do I make it run again?

@7hil
Copy link
Contributor

7hil commented Dec 13, 2014

Hi @sguada, thanks for your job on template layers. It's so useful for designing large network.

But I found it inconvenient to fill all the variables in a template including those variables we want to keep their default values. So I make a python script to add missing variable support in expand_net based on your expand_net.cpp. Those missing variables will be omitted in the template after expanded (so that they keep their default values).

See https://github.com/7hil/caffe/blob/py_template_layer/python/expand_net.py for more detail.
PS: So far I just use regexp to delete those missing variables.

@sguada
Copy link
Contributor Author

sguada commented Dec 13, 2014

@7hil it's nice to have a python version too, but could you maintain the same conventions for replacing variables. It is a good idea to remove missing variables, although it will be better that the template could define its own default values.

${name} -> value
"${name}" -> "value"

@7hil
Copy link
Contributor

7hil commented Dec 14, 2014

@sguada I've removed the $${name} replacement and add basic default value support in template.
To set the default value in template, use ${name=default}.

@sguada
Copy link
Contributor Author

sguada commented Dec 19, 2014

Thanks for your code @7hil I added your expand_net.py to this PR

@sguada
Copy link
Contributor Author

sguada commented Dec 19, 2014

The added Inception, aux_classifier and GoogleNet templates were used to generate the prototxt for GoogleNet in #1598

@7hil
Copy link
Contributor

7hil commented Dec 19, 2014

Great.
Have you planned to support default value in the template layer in expand_net.cpp? @sguada

@sguada
Copy link
Contributor Author

sguada commented Dec 23, 2014

@7hil I haven't added the support for defaults in the .cpp code, but if you want to add it, it will be great.

@shelhamer
Copy link
Member

@sguada @jeffdonahue @longjon

I think Python net specification #1733 is a more general and concise means to generate networks. I'm not entirely comfortable with building in string processing for network definitions. I worry about the proliferation of templates too when the Python net specification can make use of whatever logic and modularity one might want. This alternative does require Python however.

Is it alright to close this in favor of #1733?

@shelhamer
Copy link
Member

Closing since Python net specification was adopted instead.

@shelhamer shelhamer closed this Aug 6, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants