Optimization
collimator.optimization
Trainer
Base class for optimizing model parameters via simulation.
Should probably get a more descriptive name once we're doing other kinds of training...
Source code in collimator/optimization/training.py
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 |
|
evaluate_cost(context)
abstractmethod
Model-specific cost function, evaluated on final context
Source code in collimator/optimization/training.py
79 80 81 82 |
|
make_forward(start_time, stop_time)
Create a generic forward pass through the simulation, returning loss
Source code in collimator/optimization/training.py
84 85 86 87 88 89 90 91 92 93 94 |
|
make_loss_fn(forward, params)
Create a loss function based on a forward pass of the simulation
params
here can be any PyTree - it will get flattened to a single array
Source code in collimator/optimization/training.py
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
|
optimizable_parameters(context)
abstractmethod
Extract optimizable model-specific parameters from the context.
These should be in the form of a PyTree (e.g. tuple, dict, array, etc)
and should be the first arguments to prepare_context
.
Source code in collimator/optimization/training.py
60 61 62 63 64 65 66 67 |
|
prepare_context(context, *data)
abstractmethod
Model-specific updates to incorporate the sample data and parameters.
data
should be the combination of the output of optimizable_parameters
along with all the per-simulation "training data". Parameters will
update once per epoch, and training data will update once per sample.
Source code in collimator/optimization/training.py
69 70 71 72 73 74 75 76 77 |
|
train(training_data, sim_start_time, sim_stop_time, epochs=100)
Run the optimization loop over the training data
Source code in collimator/optimization/training.py
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 |
|