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

Dynamic file loading is unusual #3

Open
bernardopires opened this issue Apr 16, 2016 · 1 comment
Open

Dynamic file loading is unusual #3

bernardopires opened this issue Apr 16, 2016 · 1 comment

Comments

@bernardopires
Copy link

So right now the configuration file for a model looks like this:

"model": {
    "input_file": "Examples/Inputs/cifar10_input.py",
    "arch_file" : "Examples/Networks/cifar_net.py",
    "solver_file" : "Examples/Optimizer/exp_decay.py"
  },

and then the files are dynamically imported with

data_input = imp.load_source("input", hypes['model']['input_file'])
arch = imp.load_source("arch", hypes['model']['arch_file'])
solver = imp.load_source("solver", hypes['model']['solver_file'])

While this works, this opens a lot of possibilities for mistakes from the user side. The user is not forced in any way to define the necessary functions with the necessary parameters (e.g. arch.loss(H, logits, labels), arch.evaluation(H, logits, labels)).

My suggestion would be to use something equivalent to Java Interfaces. However, it seems like my suggestion goes against the python philosophy (see http://stackoverflow.com/questions/8181576/java-abstract-interface-design-in-python). So I'm opening this issue for discussion in general.

@MartinThoma
Copy link
Collaborator

Something similar as Javas interfaces are Abstrace Base Classes (ABCs). However, I don't really see the use of them. If the user does not implement the required functions (which should be well documented, of course), the toolkit will throw an error (telling him that he should implement it).

I can see two minor advantages:

  • With ABCs, it is clear without much documentation what the user needs to do. From the code. It might also be what people from the Java-world might be looking for.
  • With ABCs, it is probably easier to find the classes.
  • The users might feel more comfortable with it.

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

No branches or pull requests

2 participants