tfep.nn.flows.oriented.OrientedFlow
- class tfep.nn.flows.oriented.OrientedFlow(flow: Module, axis_point_idx: int | None = None, plane_point_idx: int | None = None, axis: Literal['x', 'y', 'z'] = 'x', plane: Literal['xy', 'yz', 'xz'] = 'xy', round_off_imprecisions: bool = True, rotate_back: bool = True, return_partial: bool = False)[source]
Bases:
PartialFlowA transformation constraining the rotational degrees of freedom.
Note
This flow currently supports only rotation in 3D space.
This flow performs the following operations: - Rotates the frame of references so that two points selected by the user lie
on an axis and plane (also selected by the user).
Removes 3 degrees of freedom (DOFs) from the input features (2 DOFs from the coordinates of the contrained point on the axis and 1 DOF from the point on the plane) and runs the remaining features through the wrapped flow.
Re-adds the 3 constrained DOFs.
Optionally, rotates the system to restore the original frame of reference.
The flow assumes that the input features have shape
(batch_size, n_dofs), and each batch sample represent a sequence of points in a 3D space. The points must must be listed so thatinput[b][3*i:3*i+3]are the x, y, and z coordinates (in this order) of thei-th point for batch sampleb.- __init__(flow: Module, axis_point_idx: int | None = None, plane_point_idx: int | None = None, axis: Literal['x', 'y', 'z'] = 'x', plane: Literal['xy', 'yz', 'xz'] = 'xy', round_off_imprecisions: bool = True, rotate_back: bool = True, return_partial: bool = False)[source]
Constructor.
- Parameters:
flow (torch.nn.Module) – The wrapped flow.
axis_point_idx (int, optional) – The index of the point that is constrained on the given axis.
Note this index must refer to the points, not the feature indices. For example,
axis_point_idx = 1will force onaxisthe point whose coordinates correspond to feature indices[3, 4, 5].plane_point_idx (int, optional) – The index of the point that is forced on the given plane.
Note this index must refer to the points, not the feature indices. For example,
plane_point_idx = 1will force onplanethe point whose coordinates correspond to feature indices[3, 4, 5].axis (Literal[‘x’, ‘y’, ‘z’], optional) – The axis on which the position of
axis_point_idxis forced.plane (Literal[‘xy’, ‘yz’, ‘xz’], optional) – The plane on which the position of
plane_point_idxis forced.round_off_imprecisions (bool, optional) – As a result of the constrains, several coordinates should be exactly 0.0, but numerical errors may cause these to deviate from it. Setting this to
Truetruncate the least significant decimal values of the constrained degrees of freedom.rotate_back (bool, optional) – If
False, the output configuration has the centroid in theorigin. Otherwise, it the centroid is restored to the original position.return_partial (bool, optional) – If
True, only the propagated indices are returned.
Methods
__init__(flow[, axis_point_idx, ...])Constructor.
add_module(name, module)Add a child module to the current module.
apply(fn)Apply
fnrecursively to every submodule (as returned by.children()) as well as self.bfloat16()Casts all floating point parameters and buffers to
bfloat16datatype.buffers([recurse])Return an iterator over module buffers.
children()Return an iterator over immediate children modules.
compile(*args, **kwargs)Compile this Module's forward using
torch.compile().cpu()Move all model parameters and buffers to the CPU.
cuda([device])Move all model parameters and buffers to the GPU.
double()Casts all floating point parameters and buffers to
doubledatatype.eval()Set the module in evaluation mode.
extra_repr()Set the extra representation of the module.
float()Casts all floating point parameters and buffers to
floatdatatype.forward(x)Transform the input configuration.
get_buffer(target)Return the buffer given by
targetif it exists, otherwise throw an error.get_extra_state()Return any extra state to include in the module's state_dict.
get_parameter(target)Return the parameter given by
targetif it exists, otherwise throw an error.get_submodule(target)Return the submodule given by
targetif it exists, otherwise throw an error.half()Casts all floating point parameters and buffers to
halfdatatype.inverse(y)Invert the forward transformation.
ipu([device])Move all model parameters and buffers to the IPU.
load_state_dict(state_dict[, strict, assign])Copy parameters and buffers from
state_dictinto this module and its descendants.modules()Return an iterator over all modules in the network.
mtia([device])Move all model parameters and buffers to the MTIA.
int: The total number of parameters that can be optimized.
named_buffers([prefix, recurse, ...])Return an iterator over module buffers, yielding both the name of the buffer as well as the buffer itself.
named_children()Return an iterator over immediate children modules, yielding both the name of the module as well as the module itself.
named_modules([memo, prefix, remove_duplicate])Return an iterator over all modules in the network, yielding both the name of the module as well as the module itself.
named_parameters([prefix, recurse, ...])Return an iterator over module parameters, yielding both the name of the parameter as well as the parameter itself.
parameters([recurse])Return an iterator over module parameters.
register_backward_hook(hook)Register a backward hook on the module.
register_buffer(name, tensor[, persistent])Add a buffer to the module.
register_forward_hook(hook, *[, prepend, ...])Register a forward hook on the module.
register_forward_pre_hook(hook, *[, ...])Register a forward pre-hook on the module.
register_full_backward_hook(hook[, prepend])Register a backward hook on the module.
register_full_backward_pre_hook(hook[, prepend])Register a backward pre-hook on the module.
register_load_state_dict_post_hook(hook)Register a post-hook to be run after module's
load_state_dict()is called.register_load_state_dict_pre_hook(hook)Register a pre-hook to be run before module's
load_state_dict()is called.register_module(name, module)Alias for
add_module().register_parameter(name, param)Add a parameter to the module.
register_state_dict_post_hook(hook)Register a post-hook for the
state_dict()method.register_state_dict_pre_hook(hook)Register a pre-hook for the
state_dict()method.requires_grad_([requires_grad])Change if autograd should record operations on parameters in this module.
set_extra_state(state)Set extra state contained in the loaded state_dict.
set_submodule(target, module)Set the submodule given by
targetif it exists, otherwise throw an error.share_memory()See
torch.Tensor.share_memory_().state_dict(*args[, destination, prefix, ...])Return a dictionary containing references to the whole state of the module.
to(*args, **kwargs)Move and/or cast the parameters and buffers.
to_empty(*, device[, recurse])Move the parameters and buffers to the specified device without copying storage.
train([mode])Set the module in training mode.
type(dst_type)Casts all parameters and buffers to
dst_type.xpu([device])Move all model parameters and buffers to the XPU.
zero_grad([set_to_none])Reset gradients of all model parameters.
Attributes
T_destinationcall_super_initdump_patchesWhether the reference frame is restored to its original orientation in the output configuration.
Wrapped flow.
If
True, only the propagated indices are returned.training- flow
Wrapped flow.
- inverse(y: Tensor) Tuple[Tensor][source]
Invert the forward transformation.
This works only if the forward transformation was performed with
rotate_backset toTrue.
- n_parameters()
int: The total number of parameters that can be optimized.
- return_partial
If
True, only the propagated indices are returned.
- rotate_back
Whether the reference frame is restored to its original orientation in the output configuration.