State¶
- class telescopic.kernels.State(x, log_prob, grad=None, extra=<factory>)¶
The states of
nchains, batch first: positions, log-densities, gradients, fields.A kernel returns states with the fields of its input states, valid at the returned positions: a state that carries gradients gets them evaluated at every new position.
extramaps names to arrays of one kernel, such as a momentum or a cached value, with the chains along their first axis. The kernel names inmarkov_fieldsthose that are part of its Markov state, and the others are caches that it checks before use. A kernel carries unchanged the fields it does not know, andtake()andput()do so for it. A state therefore carries its kernel’s caches: before handing a state to another kernel by hand, drop itsextra.- Attributes:
- put(rows, other)¶
Overwrite the chains in
rowswithother, in place.A field of
extrathatotherlacks keeps its values inrows, and a field that onlyotherhas is not added.- Parameters:
- rowsarray_like of
intor bool, or slice An index array, a mask of shape
(n,)or a slice.- other
State One chain per selected row, with the fields of this state.
- rowsarray_like of
- take(rows)¶
A copy of the chains in
rows.- Parameters:
- rowsarray_like of
intor bool, or slice An index array, a mask of shape
(n,)or a slice.
- rowsarray_like of
- Returns:
StateThe selected chains, with arrays of their own, every field of
extraincluded.