Conversation
|
Sorry, I think this needs another rebase. LMK if you need help with it. Also, can you fix the tests? It should be as simple as changing the scan access. We should probably also take a look at the conventional engines before merge, shouldn't be too difficult. |
| # cast = to_real_dtype(sim.object.data.dtype) | ||
| xp = get_array_module(sim.scan.data) | ||
| update = xp.zeros_like(sim.scan.data, dtype=sim.scan.data.dtype) | ||
| for kind, weight in self.constraints.items(): |
There was a problem hiding this comment.
Is this deterministic? It seems like it could apply the updates in arbitrary order, we may want to add sorted() if it matters
There was a problem hiding this comment.
This should be deterministic, since the updates are summed and applied after each kind * weight is calculated from the common unconstrained update and previous scan state. Example:
update += scan_affine(sim.scan.data, state.previous) * weight
|
|
||
| cost = xp.sum(xp.abs(sim.object.data - 1.0)) | ||
| cost_scale = xp.array(group.shape[-1] / prod(sim.scan.shape[:-1]), dtype=cost.dtype) | ||
| cost_scale = xp.array(group.shape[-1] / prod(sim.scan.data.shape[:-1]), dtype=cost.dtype) |
There was a problem hiding this comment.
Maybe unnecessary for this PR, but we could probably make n_pos() a method of sim.scan to avoid this repetition
|
|
||
| ## FIXME: output to Tuple? importance of array number types | ||
|
|
||
| @t.overload |
There was a problem hiding this comment.
I don't love this API, not sure what would be better. Maybe output ScanState directly? Or maybe better, keep make_raster_scan clean and include the metadata in the hook only
There was a problem hiding this comment.
I'm in favor of outputting to ScanState directly.
The grid would need to be re-calculated if not included here, but maybe it would be fine.
77911c3 to
ef9f35e
Compare
breaking with all previous h5 files, since they do not contain scan object
ef9f35e to
3bca912
Compare
- map all array-likes to numpy and then to list before json dump - coerce to numpy array when needed after loading
|
compatibility with data containing NaNs needs to be updated |
Should be addressed with the latest fix |
Now It should be actually fixed. Tested on nan-containing data with saving and loading multiple times. |
phaser/execute.py
Outdated
| state.scan.metadata['rows'] = numpy.array(state.scan.metadata.get('rows'), dtype=numpy.integer) | ||
| state.scan.metadata['rows'] = (state.scan.metadata['rows']).reshape((*new_shape, 1)) | ||
| if 'cols' in state.scan.metadata: | ||
| if isinstance(state.scan.metadata.get('cols'), list): | ||
| state.scan.metadata['cols'] = numpy.array(state.scan.metadata.get('cols'), dtype=numpy.integer) |
There was a problem hiding this comment.
My initial concern was having the rows of the right type for the regularizer, but it seems that I've already taken care of casting only if 'rows' is needed.
Seems to be ok after testing

This has been rebased on latest probe aberration merge. Still need to update and test conventional solvers
Example: affine-only updates after 800 iterations for an experiment:
