Skip to content

Commit

Permalink
Allow calling find_network with type (bayesflow-org#200)
Browse files Browse the repository at this point in the history
* in addition to strings, type (i.e., uninstantiated classes) are
  accepted as well

* allows easy use of user-defined networks
  • Loading branch information
vpratz committed Oct 9, 2024
1 parent 7fcb6ed commit 8200675
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions bayesflow/utils/dispatch/find_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,10 @@ def _(name: str, *args, **kwargs):
raise ValueError(f"Unsupported network name: '{other}'.")

return network


@find_network.register
def _(cls: type, *args, **kwargs):
# Instantiate class with the given arguments
network = cls(*args, **kwargs)
return network

0 comments on commit 8200675

Please sign in to comment.