bayespy.nodes.Take¶
- class bayespy.nodes.Take(node, indices, plate_axis=-1, **kwargs)[source]¶
Choose elements/sub-arrays along a plate axis
Basically, applies np.take on a plate axis. Allows advanced mapping of plates.
- Parameters
- nodeNode
A node to apply the take operation on.
- indicesarray of integers
Plate elements to pick along a plate axis.
- plate_axisint (negative)
The plate axis to pick elements from (default: -1).
See also
numpy.take
Examples
>>> from bayespy.nodes import Gamma, Take >>> alpha = Gamma([1, 2, 3], [1, 1, 1]) >>> x = Take(alpha, [1, 1, 2, 2, 1, 0]) >>> x.get_moments()[0] array([2., 2., 3., 3., 2., 1.])
Methods
__init__
(node, indices[, plate_axis])add_plate_axis
(to_plate)broadcasting_multiplier
(plates, *args)delete
()Delete this node and the children
get_mask
()get_shape
(ind)Return True if the node has a plotter
lower_bound_contribution
([gradient])move_plates
(from_plate, to_plate)plot
([fig])Plot the node distribution using the plotter of the node
random
()set_plotter
(plotter)Attributes
Plate multiplier is applied to messages to parents