torchGB.layers.gnet package

Submodules

torchGB.layers.gnet.attn_gnet module

torchGB.layers.gnet.attn_gnet_fast module

torchGB.layers.gnet.conv_gnet module

torchGB.layers.gnet.conv_gnet_fast module

torchGB.layers.gnet.linear_gnet module

torchGB.layers.gnet.linear_gnet_fast module

torchGB.layers.gnet.model module

class torchGB.layers.gnet.model.FastGenomicBottleNet(num_tiles: int, sizes: ~typing.Sequence[int], output_scale: ~torch.Tensor, activation_fn: ~torch.nn.modules.module.Module = <class 'torch.nn.modules.activation.ReLU'>)[source]

Bases: GenomicBottleNet

_summary_

TODO: generalize the implementation? TODO: use this implementation for fast computation of a set of adjacent tiles

Parameters:

nn (_type_) – _description_

Returns:

_description_

Return type:

_type_

forward(x: Tensor) Tensor[source]

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

init_weights() None[source]
num_tiles: int
class torchGB.layers.gnet.model.FastStochasticGenomicBottleNet(num_tiles: int, sizes: ~typing.Sequence[int], output_scale: ~torch.Tensor, activation_fn: ~torch.nn.modules.module.Module = <class 'torch.nn.modules.activation.ReLU'>)[source]

Bases: FastGenomicBottleNet

_summary_

TODO: generalize the implementation? TODO: use this implementation for fast computation of a set of adjacent tiles

Parameters:

nn (_type_) – _description_

Returns:

_description_

Return type:

_type_

forward(x: Tensor) Tensor[source]

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

init_weights() None[source]
num_tiles: int
class torchGB.layers.gnet.model.GenomicBottleNet(sizes: ~typing.Sequence[int], output_scale: float, activation_fn: ~typing.Callable[[~torch.Tensor], ~torch.Tensor] | None = <class 'torch.nn.modules.activation.ReLU'>)[source]

Bases: Module

Improved version of the variable-length g-net that uses a for-loop for initialization.

Parameters:
  • layers (nn.ModuleList) – ModuleList that contains all differentiable layers of the g-net.

  • sizes (Sequence[int]) – List of sizes for the g-net layers.

  • output_scale (float) – Scaling factor for the output of the g-net.

  • activation_fn (Optional[Callable[[Tensor], Tensor]]) – Activation function for the hidden layers. Default is ReLU.

Returns:

Prediction of the new weight.

Return type:

Tensor

forward(x: Tensor) Tensor[source]

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

init_weights() None[source]
model: Sequential
output_scale: float
sizes: Sequence[int]
class torchGB.layers.gnet.model.Reshape(*shape)[source]

Bases: Module

forward(x: Tensor) Tensor[source]

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

training: bool
class torchGB.layers.gnet.model.StochasticGenomicBottleNet(sizes: ~typing.Sequence[int], output_scale: ~torch.Tensor, activation_fn: ~typing.Callable[[~torch.Tensor], ~torch.Tensor] | None = <class 'torch.nn.modules.activation.ReLU'>)[source]

Bases: GenomicBottleNet

Improved version of the variable-length g-net that uses a for-loop for initialization.

Parameters:
  • layers (nn.ModuleList) – ModuleList that contains all differentiable layers of the g-net.

  • sizes (Sequence[int]) – List of sizes for the g-net layers.

  • output_scale (float) – Scaling factor for the output of the g-net.

  • activation_fn (Optional[Callable[[Tensor], Tensor]]) – Activation function for the hidden layers. Default is ReLU.

Returns:

Prediction of the new weight.

Return type:

Tensor

forward(x: Tensor) Tensor[source]

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

init_weights() None[source]
model: Sequential
output_scale: float
sizes: Sequence[int]
training: bool

torchGB.layers.gnet.pinv_fc_layer module

class torchGB.layers.gnet.pinv_fc_layer.PseudoInverseLinear(in_features: int, out_features: int, bias: bool = True)[source]

Bases: Module

extra_repr() str[source]

Set the extra representation of the module.

To print customized extra information, you should re-implement this method in your own modules. Both single-line and multi-line strings are acceptable.

forward(x: Tensor) Tensor[source]

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

reset_parameters() None[source]
training: bool
class torchGB.layers.gnet.pinv_fc_layer.PseudoInverseLinearFunction(*args, **kwargs)[source]

Bases: Function

static backward(ctx, grad_output)[source]

Backward pass: Compute gradients w.r.t. inputs of forward. grad_output is dL/dY

static forward(ctx, x, weight, bias)[source]

Forward pass: Standard linear transformation. y = x @ weight.T + bias

Module contents