Skip to content

Allow passing networks directly instead of using network=str(), network_kwargs=dict() #343

New issue

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

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

Already on GitHub? # to your account

Closed
LarsKue opened this issue Mar 5, 2025 · 5 comments
Assignees
Labels
feature New feature or request
Milestone

Comments

@LarsKue
Copy link
Contributor

LarsKue commented Mar 5, 2025

This has been fundamentally limited by serialization, which should become much simpler with #342.

The idea is that we want to move from this:

inference_network = FlowMatching(subnet="mlp", subnet_kwargs=dict(widths=[256, 512, 256]))

to this:

inference_network = FlowMatching(subnet=MLP(widths=[256, 512, 256]))

Advantages:

  • Intuitive code structure
  • Significantly improved transparency on which arguments are available
  • Trivially allows users to pass their own networks
  • Reduced developer load for maintaining dispatch

Disadvantages:

  • Slightly more complicated type hinting
@LarsKue LarsKue self-assigned this Mar 5, 2025
@LarsKue LarsKue added the feature New feature or request label Mar 5, 2025
@LarsKue LarsKue added this to the BayesFlow 2.0 milestone Mar 5, 2025
@LarsKue
Copy link
Contributor Author

LarsKue commented Apr 7, 2025

Now relates to #391

@LarsKue
Copy link
Contributor Author

LarsKue commented Apr 7, 2025

We will further deprecate the _kwargs pattern.

@vpratz
Copy link
Collaborator

vpratz commented Apr 11, 2025

We will further deprecate the _kwargs pattern.

Could you please detail what you mean by this and what alternative pattern you have in mind?

@LarsKue
Copy link
Contributor Author

LarsKue commented Apr 14, 2025

@vpratz You can check the behavior on the allow-networks branch. It just means that when the user passes subnet_kwargs to a model where it is not required (e.g. FlowMatching, but not CouplingFlow), they will get a warning that they should instantiate the network directly themselves. Other _kwargs are currently unaffected, such as optimal_transport_kwargs.

@vpratz
Copy link
Collaborator

vpratz commented Apr 14, 2025

I see, thanks for clarifying :)

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
feature New feature or request
Projects
Status: Done
Development

No branches or pull requests

2 participants