ptyrad.solver.ptyrad_solver#

High-level solver interface for PtyRAD workflows, including “reconstruction” and “hypertune” modes

Classes

PtyRADSolver(params[, device, seed, acc])

A wrapper class to perform ptychographic reconstruction or hyperparameter tuning.

class ptyrad.solver.ptyrad_solver.PtyRADSolver(params, device=None, seed=None, acc=None)[source]#

Bases: object

A wrapper class to perform ptychographic reconstruction or hyperparameter tuning.

The PtyRADSolver class initializes the necessary components for ptychographic reconstruction and provides methods to execute the reconstruction or perform hyperparameter tuning using Optuna.

params#

Dictionary containing all the parameters required for initialization, loss functions, constraints, model, and optional hyperparameter tuning.

Type:

dict

if_hypertune#

A flag to indicate whether hyperparameter tuning should be performed instead of regular reconstruction. Defaults to False.

Type:

bool

device#

The device to run the computations on (e.g., ‘cuda’ for GPU, ‘cpu’ for CPU). Defaults to None to let accelerate automatically decide.

Type:

str

init_initializer()[source]#

Initializes the variables and objects needed for the reconstruction process.

init_loss()[source]#

Initializes the loss function using the provided parameters.

init_constraint()[source]#

Initializes the constraint function using the provided parameters.

reconstruct()[source]#

Executes the ptychographic reconstruction process by creating the model, optimizer, and running the reconstruction loop.

hypertune()[source]#

Performs hyperparameter tuning using Optuna.

run()[source]#

A wrapper method to run the solver in either reconstruction or hyperparameter tuning mode based on the if_hypertune flag