AbstractModel#
- class torchsim.base.AbstractModel(diff=None, chunk_size=None, device=None, *args, **kwargs)[source]#
Bases:
ABC
Abstract base class for MRI simulation models with automated parameter handling.
Methods
__init__
Initialize the model with automatic parameter segregation and engine setup.
Get forward method.
Get Jacobian method.
Define broadcastable spin/environment parameters.
Define sequence parameters.
- _get_func(_func, *args, **kwargs)[source]#
Dynamically split parameters into broadcastable and non-broadcastable groups.
- Parameters:
- Returns:
Callable – A new engine accepting broadcastable parameters.
dict[str, Any] – Captured non-broadcastable parameters.
- Return type:
- _forward(*args, **kwargs)[source]#
Return a callable for forward computation. Useful for sequence optimization.
- Parameters:
*args (Any) – Positional arguments for the simulation.
**kwargs (Any) – Keyword arguments for the simulation.
- Returns:
A function that evaluates the forward model with the specified arguments.
- Return type:
callable
- _jacobian(*args, **kwargs)[source]#
Return a callable for the Jacobian computation. Useful for sequence optimization.
- Parameters:
*args (Any) – Positional arguments for the simulation.
**kwargs (Any) – Keyword arguments for the simulation.
- Returns:
A function that computes the Jacobian with respect to specified arguments.
- Return type:
callable
- __call__()[source]#
Calls both forward and jacobian methods, returning output and jacobian for sequence optimization.
- Returns:
A tuple containing the forward output and jacobian output.
- Return type: