siml.networks package

Subpackages

Submodules

siml.networks.abstract_equivariant_gnn module

class siml.networks.abstract_equivariant_gnn.AbstractEquivariantGNN(block_setting)

Bases: AbstractGCN

Abstract class for equivariant GNN.

training: bool

siml.networks.abstract_gcn module

class siml.networks.abstract_gcn.AbstractGCN(block_setting, *, create_subchain=True, residual=False, multiple_networks=None)

Bases: SimlModule

static accepts_multiple_inputs()

Abstract method to be overridden by the subclass. It shoud return bool indicating if it accepts multiple inputs.

forward(x, *args, supports=None, original_shapes=None)

Execute the NN’s forward computation.

Parameters:
  • x (numpy.ndarray or cupy.ndarray) – Input of the NN.

  • supports (list[chainer.util.CooMatrix]) – List of support inputs.

Returns:

y – Output of the NN.

Return type:

numpy.ndarray of cupy.ndarray

static is_trainable()

Abstract method to be overridden by the subclass. It shoud return bool indicating if it is trainable.

training: bool
static uses_support()

Abstract method to be overridden by the subclass. It shoud return bool indicating if it uses support inputs (sparse matrices).

siml.networks.activation module

class siml.networks.activation.Activation(block_setting)

Bases: SimlModule

Activation block.

static accepts_multiple_inputs()

Abstract method to be overridden by the subclass. It shoud return bool indicating if it accepts multiple inputs.

forward(x, supports=None, original_shapes=None)

Defines 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.

static get_name()

Abstract method to be overridden by the subclass. It shoud return str indicating its name.

static is_trainable()

Abstract method to be overridden by the subclass. It shoud return bool indicating if it is trainable.

training: bool
static uses_support()

Abstract method to be overridden by the subclass. It shoud return bool indicating if it uses support inputs (sparse matrices).

siml.networks.activations module

class siml.networks.activations.ATanh(epsilon)

Bases: Module

forward(x)

Defines 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 siml.networks.activations.DerivativeLeakyReLU(original_lrelu=None)

Bases: Module

forward(x)

Defines 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 siml.networks.activations.InversedLeakyReLU(original_lrelu=None)

Bases: Module

forward(x)

Defines 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
siml.networks.activations.atanh(x, epsilon=1e-05)
siml.networks.activations.derivative_smooth_leaky_relu(x)
siml.networks.activations.derivative_tanh(x)
siml.networks.activations.identity(x)
siml.networks.activations.inversed_smooth_leaky_relu(x)
siml.networks.activations.max_pool(x, original_shapes)
siml.networks.activations.mean(x, original_shapes)
siml.networks.activations.min(x, original_shapes)
siml.networks.activations.min_func(*args, **kwargs)
siml.networks.activations.mish(x)
siml.networks.activations.normalize(x)
siml.networks.activations.one(x)
siml.networks.activations.smooth_leaky_relu(x)
siml.networks.activations.split(x, original_shapes)

siml.networks.array2diagmat module

class siml.networks.array2diagmat.Array2Diagmat(block_setting)

Bases: SimlModule

Convert array to diagonal matrix. [n, f] -> [n, 3, 3, f]

static accepts_multiple_inputs()

Abstract method to be overridden by the subclass. It shoud return bool indicating if it accepts multiple inputs.

forward(x, supports=None, original_shapes=None)

Defines 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.

static get_name()

Abstract method to be overridden by the subclass. It shoud return str indicating its name.

static is_trainable()

Abstract method to be overridden by the subclass. It shoud return bool indicating if it is trainable.

training: bool
static uses_support()

Abstract method to be overridden by the subclass. It shoud return bool indicating if it uses support inputs (sparse matrices).

siml.networks.array2symmat module

class siml.networks.array2symmat.Array2Symmat(block_setting)

Bases: SimlModule

Convert array to symmetric matrix.

static accepts_multiple_inputs()

Abstract method to be overridden by the subclass. It shoud return bool indicating if it accepts multiple inputs.

forward(x, supports=None, original_shapes=None)

Defines 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.

static get_name()

Abstract method to be overridden by the subclass. It shoud return str indicating its name.

static is_trainable()

Abstract method to be overridden by the subclass. It shoud return bool indicating if it is trainable.

training: bool
static uses_support()

Abstract method to be overridden by the subclass. It shoud return bool indicating if it uses support inputs (sparse matrices).

siml.networks.boundary module

class siml.networks.boundary.Assignment(block_setting)

Bases: SimlModule

Assignment layer.

static accepts_multiple_inputs()

Abstract method to be overridden by the subclass. It shoud return bool indicating if it accepts multiple inputs.

forward(*xs, supports=None, original_shapes=None)

Assign values.

Parameters:

xs (List[torch.Tensor]) – 0: destination values 1: source values 2: condition values

Returns:

ys – Values assigned

Return type:

torch.Tensor

static get_name()

Abstract method to be overridden by the subclass. It shoud return str indicating its name.

static is_trainable()

Abstract method to be overridden by the subclass. It shoud return bool indicating if it is trainable.

training: bool
static uses_support()

Abstract method to be overridden by the subclass. It shoud return bool indicating if it uses support inputs (sparse matrices).

class siml.networks.boundary.Dirichlet(block_setting)

Bases: SimlModule

Dirichlet boundary condition management.

static accepts_multiple_inputs()

Abstract method to be overridden by the subclass. It shoud return bool indicating if it accepts multiple inputs.

forward(*xs, supports=None, original_shapes=None)

Take into account Dirichlet boundary condition.

Parameters:

xs (List[torch.Tensor]) – 0: Variable values 1: Dirichlet values.

Returns:

ys – Variable values with Dirichlet.

Return type:

torch.Tensor

static get_name()

Abstract method to be overridden by the subclass. It shoud return str indicating its name.

static is_trainable()

Abstract method to be overridden by the subclass. It shoud return bool indicating if it is trainable.

training: bool
static uses_support()

Abstract method to be overridden by the subclass. It shoud return bool indicating if it uses support inputs (sparse matrices).

class siml.networks.boundary.Interaction(block_setting)

Bases: SimlModule

Interaction layer.

static accepts_multiple_inputs()

Abstract method to be overridden by the subclass. It shoud return bool indicating if it accepts multiple inputs.

forward(*xs, supports=None, original_shapes=None)

Compute interactions between two meshes.

Parameters:
  • xs (List[torch.Tensor]) – 0: self values (length = n) or 0: self values (length = n) 1: other values (lengh = m)

  • supports (List) – 0: incidence matrix from other to self (n x m matrix)

Returns:

ys – Interaction value (length = n)

Return type:

torch.Tensor

static get_name()

Abstract method to be overridden by the subclass. It shoud return str indicating its name.

static is_trainable()

Abstract method to be overridden by the subclass. It shoud return bool indicating if it is trainable.

training: bool
static uses_support()

Abstract method to be overridden by the subclass. It shoud return bool indicating if it uses support inputs (sparse matrices).

class siml.networks.boundary.NeumannDecoder(block_setting, reference_block)

Bases: SimlModule

Decoder for gradient with Neumann condition.

SUPPORTED_ACTIVATION_NAMES = ['identity', 'leaky_relu']
static accepts_multiple_inputs()

Abstract method to be overridden by the subclass. It shoud return bool indicating if it accepts multiple inputs.

forward(*xs, supports=None, original_shapes=None)

Take into account Neumann boundary condition using IsoGCN.

Parameters:

xs (List[torch.Tensor]) – 0: Encoded values 1: Non encoded values (input to the entire NN)

Returns:

ys – Embedded Neumann values multiplied with normal vectors.

Return type:

torch.Tensor

static get_name()

Abstract method to be overridden by the subclass. It shoud return str indicating its name.

static is_trainable()

Abstract method to be overridden by the subclass. It shoud return bool indicating if it is trainable.

training: bool
static uses_support()

Abstract method to be overridden by the subclass. It shoud return bool indicating if it uses support inputs (sparse matrices).

validate()
class siml.networks.boundary.NeumannEncoder(block_setting, reference_block)

Bases: SimlModule

Encoder for Neumann condition.

static accepts_multiple_inputs()

Abstract method to be overridden by the subclass. It shoud return bool indicating if it accepts multiple inputs.

property activations
forward(*xs, supports=None, original_shapes=None)

Take into account Neumann boundary condition using IsoGCN.

Parameters:

xs (List[torch.Tensor]) – 0: Variable values (not encoded) 1: Neumann values multiplied with normal vectors or 0: Variable values (not encoded) 1: Neumann values 2: Surface weighted normal vectors

Returns:

ys – Embedded Neumann values multiplied with normal vectors.

Return type:

torch.Tensor

static get_name()

Abstract method to be overridden by the subclass. It shoud return str indicating its name.

static is_trainable()

Abstract method to be overridden by the subclass. It shoud return bool indicating if it is trainable.

property linears
training: bool
static uses_support()

Abstract method to be overridden by the subclass. It shoud return bool indicating if it uses support inputs (sparse matrices).

property weights
class siml.networks.boundary.NeumannIsoGCN(block_setting, reference_block)

Bases: SimlModule

Neumann boundary condition management using IsoGCN.

static accepts_multiple_inputs()

Abstract method to be overridden by the subclass. It shoud return bool indicating if it accepts multiple inputs.

forward(*xs, supports=None, original_shapes=None)

Take into account Neumann boundary condition using IsoGCN.

Parameters:

xs (List[torch.Tensor]) – 0: Gradient values without Neumann. 1: Inversed moment matrices. 2: Neumann values multiplied with normal vectors.

Returns:

ys – Gradient values with Neumann.

Return type:

torch.Tensor

static get_name()

Abstract method to be overridden by the subclass. It shoud return str indicating its name.

static is_trainable()

Abstract method to be overridden by the subclass. It shoud return bool indicating if it is trainable.

training: bool
static uses_support()

Abstract method to be overridden by the subclass. It shoud return bool indicating if it uses support inputs (sparse matrices).

siml.networks.concatenator module

class siml.networks.concatenator.Concatenator(block_setting)

Bases: SimlModule

Concatenation operation block.

static accepts_multiple_inputs()

Abstract method to be overridden by the subclass. It shoud return bool indicating if it accepts multiple inputs.

forward(*xs, op=None, supports=None, original_shapes=None)

Defines 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.

static get_name()

Abstract method to be overridden by the subclass. It shoud return str indicating its name.

static is_trainable()

Abstract method to be overridden by the subclass. It shoud return bool indicating if it is trainable.

training: bool
static uses_support()

Abstract method to be overridden by the subclass. It shoud return bool indicating if it uses support inputs (sparse matrices).

siml.networks.deepsets module

class siml.networks.deepsets.DeepSets(block_setting)

Bases: SimlModule

Permutation equivalent layer published in https://arxiv.org/abs/1703.06114 .

static accepts_multiple_inputs()

Abstract method to be overridden by the subclass. It shoud return bool indicating if it accepts multiple inputs.

static get_name()

Abstract method to be overridden by the subclass. It shoud return str indicating its name.

static is_trainable()

Abstract method to be overridden by the subclass. It shoud return bool indicating if it is trainable.

training: bool
static uses_support()

Abstract method to be overridden by the subclass. It shoud return bool indicating if it uses support inputs (sparse matrices).

siml.networks.einops module

class siml.networks.einops.Rearrange(block_setting)

Bases: SimlModule

Apply einops.rearrange.

static accepts_multiple_inputs()

Abstract method to be overridden by the subclass. It shoud return bool indicating if it accepts multiple inputs.

forward(x, supports=None, original_shapes=None)

Defines 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.

static get_name()

Abstract method to be overridden by the subclass. It shoud return str indicating its name.

static is_trainable()

Abstract method to be overridden by the subclass. It shoud return bool indicating if it is trainable.

training: bool
static uses_support()

Abstract method to be overridden by the subclass. It shoud return bool indicating if it uses support inputs (sparse matrices).

siml.networks.einsum module

class siml.networks.einsum.EinSum(block_setting)

Bases: SimlModule

EinSum block.

static accepts_multiple_inputs()

Abstract method to be overridden by the subclass. It shoud return bool indicating if it accepts multiple inputs.

forward(*xs, supports=None, original_shapes=None)

Calculate EinSum.

static get_name()

Abstract method to be overridden by the subclass. It shoud return str indicating its name.

static is_trainable()

Abstract method to be overridden by the subclass. It shoud return bool indicating if it is trainable.

training: bool
static uses_support()

Abstract method to be overridden by the subclass. It shoud return bool indicating if it uses support inputs (sparse matrices).

siml.networks.gcn module

class siml.networks.gcn.GCN(block_setting)

Bases: AbstractGCN

Graph Convolutional network based on https://arxiv.org/abs/1609.02907 .

static get_name()

Abstract method to be overridden by the subclass. It shoud return str indicating its name.

training: bool

siml.networks.group module

class siml.networks.group.Group(block_setting, model_setting)

Bases: SimlModule

static accepts_multiple_inputs()

Abstract method to be overridden by the subclass. It shoud return bool indicating if it accepts multiple inputs.

broadcast(a, x, operator)
calculate_residual(x, ref)
static create_group_setting(block_setting, model_setting)
forward_implicit(x, supports, original_shapes=None)
forward_time_series(x, supports, original_shapes=None)
forward_w_loop(x, supports, original_shapes=None)
forward_wo_loop(x, supports, original_shapes=None)
generate_inputs(dict_predecessors)
generate_outputs(y)
static get_name()

Abstract method to be overridden by the subclass. It shoud return str indicating its name.

property input_names
static is_trainable()

Abstract method to be overridden by the subclass. It shoud return bool indicating if it is trainable.

operate(x, y, operator)
property output_names
static sum_dim_if_needed(dim)
training: bool
static uses_support()

Abstract method to be overridden by the subclass. It shoud return bool indicating if it uses support inputs (sparse matrices).

siml.networks.id_mlp module

class siml.networks.id_mlp.IdMLP(block_setting, *, create_linears=True, create_activations=True, create_dropouts=True, no_parameter=False, residual_dimension=None, **kwargs)

Bases: SimlModule

Multi Layer Perceptron with adding the identity.

static accepts_multiple_inputs()

Abstract method to be overridden by the subclass. It shoud return bool indicating if it accepts multiple inputs.

static get_name()

Abstract method to be overridden by the subclass. It shoud return str indicating its name.

static is_trainable()

Abstract method to be overridden by the subclass. It shoud return bool indicating if it is trainable.

training: bool
static uses_support()

Abstract method to be overridden by the subclass. It shoud return bool indicating if it uses support inputs (sparse matrices).

siml.networks.identity module

class siml.networks.identity.Identity(block_setting)

Bases: SimlModule

Identity block.

static accepts_multiple_inputs()

Abstract method to be overridden by the subclass. It shoud return bool indicating if it accepts multiple inputs.

forward(*x, supports=None, original_shapes=None)

Defines 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.

static get_name()

Abstract method to be overridden by the subclass. It shoud return str indicating its name.

static is_trainable()

Abstract method to be overridden by the subclass. It shoud return bool indicating if it is trainable.

training: bool
static uses_support()

Abstract method to be overridden by the subclass. It shoud return bool indicating if it uses support inputs (sparse matrices).

siml.networks.integration module

class siml.networks.integration.Integration(block_setting)

Bases: SimlModule

Integration block.

static accepts_multiple_inputs()

Abstract method to be overridden by the subclass. It shoud return bool indicating if it accepts multiple inputs.

forward(x, supports=None, original_shapes=None)

Defines 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.

static get_name()

Abstract method to be overridden by the subclass. It shoud return str indicating its name.

static is_trainable()

Abstract method to be overridden by the subclass. It shoud return bool indicating if it is trainable.

training: bool
static uses_support()

Abstract method to be overridden by the subclass. It shoud return bool indicating if it uses support inputs (sparse matrices).

siml.networks.iso_gcn module

class siml.networks.iso_gcn.IsoGCN(block_setting)

Bases: AbstractEquivariantGNN

IsoGCN according to https://arxiv.org/abs/2005.06316 .

static accepts_multiple_inputs()

Abstract method to be overridden by the subclass. It shoud return bool indicating if it accepts multiple inputs.

static get_name()

Abstract method to be overridden by the subclass. It shoud return str indicating its name.

training: bool

siml.networks.lstm module

class siml.networks.lstm.LSTM(block_setting)

Bases: SimlModule

LSTM layer.

static accepts_multiple_inputs()

Abstract method to be overridden by the subclass. It shoud return bool indicating if it accepts multiple inputs.

static get_name()

Abstract method to be overridden by the subclass. It shoud return str indicating its name.

static is_trainable()

Abstract method to be overridden by the subclass. It shoud return bool indicating if it is trainable.

training: bool
static uses_support()

Abstract method to be overridden by the subclass. It shoud return bool indicating if it uses support inputs (sparse matrices).

siml.networks.message_passing module

class siml.networks.message_passing.MessagePassing(block_setting)

Bases: AbstractGCN

Message passing layer based on https://arxiv.org/abs/1704.01212.

static get_name()

Abstract method to be overridden by the subclass. It shoud return str indicating its name.

make_reduce_matrix(nadj, *, mean=False)
training: bool

siml.networks.mlp module

class siml.networks.mlp.MLP(block_setting, **kwargs)

Bases: SimlModule

Multi Layer Perceptron.

static accepts_multiple_inputs()

Abstract method to be overridden by the subclass. It shoud return bool indicating if it accepts multiple inputs.

static get_name()

Abstract method to be overridden by the subclass. It shoud return str indicating its name.

static is_trainable()

Abstract method to be overridden by the subclass. It shoud return bool indicating if it is trainable.

training: bool
static uses_support()

Abstract method to be overridden by the subclass. It shoud return bool indicating if it uses support inputs (sparse matrices).

siml.networks.nan_mlp module

class siml.networks.nan_mlp.NaNMLP(block_setting, **kwargs)

Bases: MLP

Multi Layer Perceptron with NaN handling.

static accepts_multiple_inputs()

Abstract method to be overridden by the subclass. It shoud return bool indicating if it accepts multiple inputs.

static get_name()

Abstract method to be overridden by the subclass. It shoud return str indicating its name.

static is_trainable()

Abstract method to be overridden by the subclass. It shoud return bool indicating if it is trainable.

training: bool
static uses_support()

Abstract method to be overridden by the subclass. It shoud return bool indicating if it uses support inputs (sparse matrices).

siml.networks.network module

class siml.networks.network.Network(model_setting, trainer_setting)

Bases: Module

clip_if_needed()
clip_uniform_if_needed(clip_grad_value: float, clip_grad_norm: float) None
dict_block_class = {'accessor': <class 'siml.networks.reshape.Accessor'>, 'activation': <class 'siml.networks.activation.Activation'>, 'adjustable_mlp': <class 'siml.networks.mlp.MLP'>, 'array2diagmat': <class 'siml.networks.array2diagmat.Array2Diagmat'>, 'array2symmat': <class 'siml.networks.array2symmat.Array2Symmat'>, 'assignment': <class 'siml.networks.boundary.Assignment'>, 'cluster_gcn': <class 'siml.networks.pyg.cluster_gcn.ClusterGCN'>, 'concatenator': <class 'siml.networks.concatenator.Concatenator'>, 'contraction': <class 'siml.networks.tensor_operations.Contraction'>, 'deepsets': <class 'siml.networks.deepsets.DeepSets'>, 'dirichlet': <class 'siml.networks.boundary.Dirichlet'>, 'distributor': <class 'siml.networks.reducer.Reducer'>, 'einsum': <class 'siml.networks.einsum.EinSum'>, 'equivariant_mlp': <class 'siml.networks.tensor_operations.EquivariantMLP'>, 'equivariant_tcn': <class 'siml.networks.tcn.EquivariantTCN'>, 'features_to_time_series': <class 'siml.networks.reshape.FeaturesToTimeSeries'>, 'gcn': <class 'siml.networks.gcn.GCN'>, 'gcnii': <class 'siml.networks.pyg.gcnii.GCNII'>, 'gin': <class 'siml.networks.pyg.gin.GIN'>, 'group': <class 'siml.networks.group.Group'>, 'id_mlp': <class 'siml.networks.id_mlp.IdMLP'>, 'identity': <class 'siml.networks.identity.Identity'>, 'integration': <class 'siml.networks.integration.Integration'>, 'interaction': <class 'siml.networks.boundary.Interaction'>, 'iso_gcn': <class 'siml.networks.iso_gcn.IsoGCN'>, 'lstm': <class 'siml.networks.lstm.LSTM'>, 'message_passing': <class 'siml.networks.message_passing.MessagePassing'>, 'mlp': <class 'siml.networks.mlp.MLP'>, 'nan_mlp': <class 'siml.networks.nan_mlp.NaNMLP'>, 'neumann_decoder': <class 'siml.networks.boundary.NeumannDecoder'>, 'neumann_encoder': <class 'siml.networks.boundary.NeumannEncoder'>, 'neumann_isogcn': <class 'siml.networks.boundary.NeumannIsoGCN'>, 'normalized_mlp': <class 'siml.networks.normalized_mlp.NormalizedMLP'>, 'penn': <class 'siml.networks.penn.PENN'>, 'pinv_mlp': <class 'siml.networks.pinv_mlp.PInvMLP'>, 'projection': <class 'siml.networks.projection.Projection'>, 'proportional': <class 'siml.networks.proportional.Proportional'>, 'rearrange': <class 'siml.networks.einops.Rearrange'>, 'reducer': <class 'siml.networks.reducer.Reducer'>, 'reshape': <class 'siml.networks.reshape.Reshape'>, 'set_transformer_decoder': <class 'siml.networks.set_transformer.SetTransformerDecoder'>, 'set_transformer_encoder': <class 'siml.networks.set_transformer.SetTransformerEncoder'>, 'share': <class 'siml.networks.share.Share'>, 'spmm': <class 'siml.networks.spmm.SpMM'>, 'symmat2array': <class 'siml.networks.symmat2array.Symmat2Array'>, 'tcn': <class 'siml.networks.tcn.TCN'>, 'tensor_product': <class 'siml.networks.tensor_operations.TensorProduct'>, 'threshold': <class 'siml.networks.threshold.Threshold'>, 'time_norm': <class 'siml.networks.time_norm.TimeNorm'>, 'time_series_to_features': <class 'siml.networks.reshape.TimeSeriesToFeatures'>, 'translator': <class 'siml.networks.translator.Translator'>, 'upper_limit': <class 'siml.networks.upper_limit.UpperLimit'>}
draw(output_directory, *, stem=None)
forward(x_)

Defines 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.

get_loss_coeffs()
get_loss_keys()
get_losses()
reset()
training: bool
siml.networks.network.add_block(block)

Add block definition to siml.

Parameters:

block (siml.network.SimlModule-like) – User defined block.

siml.networks.normalized_mlp module

class siml.networks.normalized_mlp.NormalizedMLP(block_setting, *, create_linears=True, create_activations=True, create_dropouts=True, no_parameter=False, residual_dimension=None, **kwargs)

Bases: SimlModule

Multi Layer Perceptron with the normalized weight.

static accepts_multiple_inputs()

Abstract method to be overridden by the subclass. It shoud return bool indicating if it accepts multiple inputs.

static get_name()

Abstract method to be overridden by the subclass. It shoud return str indicating its name.

static is_trainable()

Abstract method to be overridden by the subclass. It shoud return bool indicating if it is trainable.

training: bool
static uses_support()

Abstract method to be overridden by the subclass. It shoud return bool indicating if it uses support inputs (sparse matrices).

siml.networks.penn module

class siml.networks.penn.PENN(block_setting)

Bases: AbstractEquivariantGNN

Physics-Embedded Neural Network.

static accepts_multiple_inputs()

Abstract method to be overridden by the subclass. It shoud return bool indicating if it accepts multiple inputs.

static get_name()

Abstract method to be overridden by the subclass. It shoud return str indicating its name.

training: bool

siml.networks.pinv_mlp module

class siml.networks.pinv_mlp.PInvLinear(ref_linear, option)

Bases: Module

property bias

Return inverse bias.

forward(x)

Defines 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
property weight

Return pseudo inversed weight.

class siml.networks.pinv_mlp.PInvMLP(block_setting, reference_block)

Bases: SimlModule

Pseudo inverse of Multi Layer Perceptron.

static accepts_multiple_inputs()

Abstract method to be overridden by the subclass. It shoud return bool indicating if it accepts multiple inputs.

static get_name()

Abstract method to be overridden by the subclass. It shoud return str indicating its name.

static is_trainable()

Abstract method to be overridden by the subclass. It shoud return bool indicating if it is trainable.

training: bool
static uses_support()

Abstract method to be overridden by the subclass. It shoud return bool indicating if it uses support inputs (sparse matrices).

siml.networks.projection module

class siml.networks.projection.Projection(block_setting)

Bases: SimlModule

static accepts_multiple_inputs()

Abstract method to be overridden by the subclass. It shoud return bool indicating if it accepts multiple inputs.

forward(*xs, supports=None, original_shapes=None) Tensor

Defines 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.

static get_name()

Abstract method to be overridden by the subclass. It shoud return str indicating its name.

static is_trainable()

Abstract method to be overridden by the subclass. It shoud return bool indicating if it is trainable.

training: bool
static uses_support()

Abstract method to be overridden by the subclass. It shoud return bool indicating if it uses support inputs (sparse matrices).

siml.networks.proportional module

class siml.networks.proportional.Proportional(block_setting)

Bases: SimlModule

Proportional layer.

static accepts_multiple_inputs()

Abstract method to be overridden by the subclass. It shoud return bool indicating if it accepts multiple inputs.

static get_name()

Abstract method to be overridden by the subclass. It shoud return str indicating its name.

static is_trainable()

Abstract method to be overridden by the subclass. It shoud return bool indicating if it is trainable.

training: bool
static uses_support()

Abstract method to be overridden by the subclass. It shoud return bool indicating if it uses support inputs (sparse matrices).

siml.networks.reducer module

class siml.networks.reducer.Reducer(block_setting)

Bases: SimlModule

Broadcastive operation block.

static accepts_multiple_inputs()

Abstract method to be overridden by the subclass. It shoud return bool indicating if it accepts multiple inputs.

forward(*xs, op=None, supports=None, original_shapes=None)

Defines 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.

static get_name()

Abstract method to be overridden by the subclass. It shoud return str indicating its name.

static is_trainable()

Abstract method to be overridden by the subclass. It shoud return bool indicating if it is trainable.

training: bool
static uses_support()

Abstract method to be overridden by the subclass. It shoud return bool indicating if it uses support inputs (sparse matrices).

siml.networks.reshape module

class siml.networks.reshape.Accessor(block_setting)

Bases: SimlModule

Access data using the given index.

static accepts_multiple_inputs()

Abstract method to be overridden by the subclass. It shoud return bool indicating if it accepts multiple inputs.

forward(x, supports=None, original_shapes=None)

Defines 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.

static get_name()

Abstract method to be overridden by the subclass. It shoud return str indicating its name.

static is_trainable()

Abstract method to be overridden by the subclass. It shoud return bool indicating if it is trainable.

training: bool
static uses_support()

Abstract method to be overridden by the subclass. It shoud return bool indicating if it uses support inputs (sparse matrices).

class siml.networks.reshape.FeaturesToTimeSeries(block_setting)

Bases: SimlModule

Convert feature axes to time series.

static accepts_multiple_inputs()

Abstract method to be overridden by the subclass. It shoud return bool indicating if it accepts multiple inputs.

forward(x, supports=None, original_shapes=None)

Defines 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.

static get_name()

Abstract method to be overridden by the subclass. It shoud return str indicating its name.

static is_trainable()

Abstract method to be overridden by the subclass. It shoud return bool indicating if it is trainable.

training: bool
static uses_support()

Abstract method to be overridden by the subclass. It shoud return bool indicating if it uses support inputs (sparse matrices).

class siml.networks.reshape.Reshape(block_setting)

Bases: SimlModule

Reshape block.

static accepts_multiple_inputs()

Abstract method to be overridden by the subclass. It shoud return bool indicating if it accepts multiple inputs.

forward(x, supports=None, original_shapes=None)

Defines 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.

static get_name()

Abstract method to be overridden by the subclass. It shoud return str indicating its name.

static is_trainable()

Abstract method to be overridden by the subclass. It shoud return bool indicating if it is trainable.

training: bool
static uses_support()

Abstract method to be overridden by the subclass. It shoud return bool indicating if it uses support inputs (sparse matrices).

class siml.networks.reshape.TimeSeriesToFeatures(block_setting)

Bases: SimlModule

Convert time series axes to features.

static accepts_multiple_inputs()

Abstract method to be overridden by the subclass. It shoud return bool indicating if it accepts multiple inputs.

forward(x, supports=None, original_shapes=None)

Defines 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.

static get_name()

Abstract method to be overridden by the subclass. It shoud return str indicating its name.

static is_trainable()

Abstract method to be overridden by the subclass. It shoud return bool indicating if it is trainable.

training: bool
static uses_support()

Abstract method to be overridden by the subclass. It shoud return bool indicating if it uses support inputs (sparse matrices).

siml.networks.set_transformer module

Set Transformer implementation based on https://arxiv.org/abs/1810.00825 and the official implementation https://github.com/juho-lee/set_transformer .

class siml.networks.set_transformer.ISAB(dim_in, dim_out, num_heads, layer_norm, activation, n_inducing_point=None)

Bases: Module

ISAB: the Induced Set Attention Block. It maps [n, d_in] -> [n, d_out], with inducing points, therefore it takes O(n n_induce), where n_induce is the number of the inducing points.

forward(X)

Defines 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 siml.networks.set_transformer.MAB(dim_Q, dim_K, dim_V, num_heads, activation, layer_norm)

Bases: Module

MAB: the Multihead Attention Block. It maps [n, d_in] x [n, d_in] -> [n, d_out].

forward(Q, K)

Defines 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 siml.networks.set_transformer.PMA(dim, num_heads, num_seeds, activation, layer_norm)

Bases: Module

PMA: Pooling by Multihead Attention. It maps [n, d_in] -> [k, d_out], where k is the number of the output vectors.

forward(X)

Defines 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 siml.networks.set_transformer.SAB(dim_in, dim_out, num_heads, layer_norm, activation, n_inducing_point=None)

Bases: Module

SAB: the Set Attention Block. It maps [n, d_in] -> [n, d_out], without inducing points, therefore it takes O(n^2).

forward(X)

Defines 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 siml.networks.set_transformer.SetTransformerDecoder(block_setting)

Bases: SimlModule

Set Transformer’s encoder based on https://arxiv.org/abs/1810.00825 .

static accepts_multiple_inputs()

Abstract method to be overridden by the subclass. It shoud return bool indicating if it accepts multiple inputs.

static get_name()

Abstract method to be overridden by the subclass. It shoud return str indicating its name.

static is_trainable()

Abstract method to be overridden by the subclass. It shoud return bool indicating if it is trainable.

training: bool
static uses_support()

Abstract method to be overridden by the subclass. It shoud return bool indicating if it uses support inputs (sparse matrices).

class siml.networks.set_transformer.SetTransformerEncoder(block_setting)

Bases: SimlModule

Set Transformer’s encoder based on https://arxiv.org/abs/1810.00825 .

static accepts_multiple_inputs()

Abstract method to be overridden by the subclass. It shoud return bool indicating if it accepts multiple inputs.

static get_name()

Abstract method to be overridden by the subclass. It shoud return str indicating its name.

static is_trainable()

Abstract method to be overridden by the subclass. It shoud return bool indicating if it is trainable.

training: bool
static uses_support()

Abstract method to be overridden by the subclass. It shoud return bool indicating if it uses support inputs (sparse matrices).

siml.networks.share module

class siml.networks.share.Share(block_setting, reference_block)

Bases: SimlModule

The same module as the specified reference.

static accepts_multiple_inputs()

Abstract method to be overridden by the subclass. It shoud return bool indicating if it accepts multiple inputs.

static get_name()

Abstract method to be overridden by the subclass. It shoud return str indicating its name.

static is_trainable()

Abstract method to be overridden by the subclass. It shoud return bool indicating if it is trainable.

property linears
training: bool
static uses_support()

Abstract method to be overridden by the subclass. It shoud return bool indicating if it uses support inputs (sparse matrices).

siml.networks.siml_module module

class siml.networks.siml_module.SimlModule(block_setting, *, create_linears=True, create_activations=True, create_dropouts=True, no_parameter=False, residual_dimension=None, **kwargs)

Bases: Module

abstract static accepts_multiple_inputs()

Abstract method to be overridden by the subclass. It shoud return bool indicating if it accepts multiple inputs.

create_activation(activation_settings=None)
create_activations(activation_settings=None, residual=None)
create_dropout_ratios(dropouts=None)
create_linears(nodes=None, bias=None)
forward(x, supports=None, original_shapes=None)

Defines 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.

classmethod get_n_nodes(block_setting, predecessors, dict_block_setting, input_length, output_length, model_setting)

Get the number of input and output nodes.

Parameters:
  • block_setting (siml.setting.BlockSetting) – BlockSetting object of the block.

  • predecessors (tuple[str]) – List of predecessor names.

  • dict_block_setting (dict[siml.setting.BlockSetting]) – Dict of all BlockSetting objects.

  • input_length (int or dict[int]) – Input length.

  • output_length (int or dict[int]) – Output length.

  • model_setting (siml.setting.ModelSetting) – ModelSetting object.

Returns:

  • input_node (int) – The number of the input nodes.

  • output_node (int) – The number of the output nodes.

abstract static get_name()

Abstract method to be overridden by the subclass. It shoud return str indicating its name.

abstract static is_trainable()

Abstract method to be overridden by the subclass. It shoud return bool indicating if it is trainable.

reset()
training: bool
abstract static uses_support()

Abstract method to be overridden by the subclass. It shoud return bool indicating if it uses support inputs (sparse matrices).

siml.networks.sparse module

siml.networks.sparse.mul(sparse, tensor)

Multiply sparse tensors and tensors.

Parameters:
  • sparses (torch.sparse_coo_tensor) –

  • tensor (torch.Tensor) –

Return type:

torch.Tensor

siml.networks.spmm module

class siml.networks.spmm.SpMM(block_setting)

Bases: AbstractGCN

Layer to compute sparse matrix times dence matrix.

static accepts_multiple_inputs()

Abstract method to be overridden by the subclass. It shoud return bool indicating if it accepts multiple inputs.

static get_name()

Abstract method to be overridden by the subclass. It shoud return str indicating its name.

static is_trainable()

Abstract method to be overridden by the subclass. It shoud return bool indicating if it is trainable.

training: bool
static uses_support()

Abstract method to be overridden by the subclass. It shoud return bool indicating if it uses support inputs (sparse matrices).

siml.networks.symmat2array module

class siml.networks.symmat2array.Symmat2Array(block_setting)

Bases: SimlModule

Convert symmetric matrix to array.

static accepts_multiple_inputs()

Abstract method to be overridden by the subclass. It shoud return bool indicating if it accepts multiple inputs.

forward(x, supports=None, original_shapes=None)

Defines 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.

static get_name()

Abstract method to be overridden by the subclass. It shoud return str indicating its name.

static is_trainable()

Abstract method to be overridden by the subclass. It shoud return bool indicating if it is trainable.

training: bool
static uses_support()

Abstract method to be overridden by the subclass. It shoud return bool indicating if it uses support inputs (sparse matrices).

siml.networks.tcn module

class siml.networks.tcn.EquivariantTCN(block_setting)

Bases: SimlModule

E(n)-equivariant TCN layer.

static accepts_multiple_inputs()

Abstract method to be overridden by the subclass. It shoud return bool indicating if it accepts multiple inputs.

static get_name()

Abstract method to be overridden by the subclass. It shoud return str indicating its name.

static is_trainable()

Abstract method to be overridden by the subclass. It shoud return bool indicating if it is trainable.

training: bool
static uses_support()

Abstract method to be overridden by the subclass. It shoud return bool indicating if it uses support inputs (sparse matrices).

class siml.networks.tcn.TCN(block_setting)

Bases: SimlModule

Temporal Convolutional Networks (TCN) https://arxiv.org/abs/1803.01271 .

static accepts_multiple_inputs()

Abstract method to be overridden by the subclass. It shoud return bool indicating if it accepts multiple inputs.

static get_name()

Abstract method to be overridden by the subclass. It shoud return str indicating its name.

static is_trainable()

Abstract method to be overridden by the subclass. It shoud return bool indicating if it is trainable.

training: bool
static uses_support()

Abstract method to be overridden by the subclass. It shoud return bool indicating if it uses support inputs (sparse matrices).

siml.networks.tensor_operations module

class siml.networks.tensor_operations.Contraction(block_setting)

Bases: SimlModule

Contraction block.

static accepts_multiple_inputs()

Abstract method to be overridden by the subclass. It shoud return bool indicating if it accepts multiple inputs.

forward(*xs, supports=None, original_shapes=None)

Calculate tensor contraction of rank n ( > m) and m tensors sum_{l_1, …, l_m} A_{i,k_1,k_2,…,l_1,l_2,…,l_{m}} B_{i,l_1,l_2,…,l_m}

static get_name()

Abstract method to be overridden by the subclass. It shoud return str indicating its name.

static is_trainable()

Abstract method to be overridden by the subclass. It shoud return bool indicating if it is trainable.

training: bool
static uses_support()

Abstract method to be overridden by the subclass. It shoud return bool indicating if it uses support inputs (sparse matrices).

class siml.networks.tensor_operations.EquivariantMLP(block_setting)

Bases: SimlModule

E(n) equivariant MLP block.

static accepts_multiple_inputs()

Abstract method to be overridden by the subclass. It shoud return bool indicating if it accepts multiple inputs.

static get_name()

Abstract method to be overridden by the subclass. It shoud return str indicating its name.

static is_trainable()

Abstract method to be overridden by the subclass. It shoud return bool indicating if it is trainable.

training: bool
static uses_support()

Abstract method to be overridden by the subclass. It shoud return bool indicating if it uses support inputs (sparse matrices).

class siml.networks.tensor_operations.TensorProduct(block_setting)

Bases: SimlModule

Tensor product block.

static accepts_multiple_inputs()

Abstract method to be overridden by the subclass. It shoud return bool indicating if it accepts multiple inputs.

forward(*xs, supports=None, original_shapes=None)

Calculate tensor product of rank n and m tensors A_{i,k_1,k_2,…,k_m} B_{i,l_1,l_2,…,l_m}

static get_name()

Abstract method to be overridden by the subclass. It shoud return str indicating its name.

static is_trainable()

Abstract method to be overridden by the subclass. It shoud return bool indicating if it is trainable.

training: bool
static uses_support()

Abstract method to be overridden by the subclass. It shoud return bool indicating if it uses support inputs (sparse matrices).

siml.networks.threshold module

class siml.networks.threshold.Threshold(block_setting)

Bases: SimlModule

DEFALUT_THRESHOLD = 0.0
static accepts_multiple_inputs()

Abstract method to be overridden by the subclass. It shoud return bool indicating if it accepts multiple inputs.

forward(x: Tensor, supports=None, original_shapes=None) Tensor

Defines 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.

static get_name()

Abstract method to be overridden by the subclass. It shoud return str indicating its name.

static is_trainable()

Abstract method to be overridden by the subclass. It shoud return bool indicating if it is trainable.

training: bool
static uses_support()

Abstract method to be overridden by the subclass. It shoud return bool indicating if it uses support inputs (sparse matrices).

siml.networks.time_norm module

class siml.networks.time_norm.TimeNorm(block_setting)

Bases: SimlModule

Normalization for time series data which makes x[t=0, …] = 0.

static accepts_multiple_inputs()

Abstract method to be overridden by the subclass. It shoud return bool indicating if it accepts multiple inputs.

forward(x, supports=None, original_shapes=None)

Defines 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.

static get_name()

Abstract method to be overridden by the subclass. It shoud return str indicating its name.

static is_trainable()

Abstract method to be overridden by the subclass. It shoud return bool indicating if it is trainable.

training: bool
static uses_support()

Abstract method to be overridden by the subclass. It shoud return bool indicating if it uses support inputs (sparse matrices).

siml.networks.translator module

class siml.networks.translator.Translator(block_setting)

Bases: SimlModule

Translation block.

static accepts_multiple_inputs()

Abstract method to be overridden by the subclass. It shoud return bool indicating if it accepts multiple inputs.

static get_name()

Abstract method to be overridden by the subclass. It shoud return str indicating its name.

static is_trainable()

Abstract method to be overridden by the subclass. It shoud return bool indicating if it is trainable.

training: bool
static uses_support()

Abstract method to be overridden by the subclass. It shoud return bool indicating if it uses support inputs (sparse matrices).

siml.networks.upper_limit module

class siml.networks.upper_limit.UpperLimit(block_setting)

Bases: SimlModule

static accepts_multiple_inputs()

Abstract method to be overridden by the subclass. It shoud return bool indicating if it accepts multiple inputs.

forward(*xs, supports=None, original_shapes=None) Tensor

Defines 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.

static get_name()

Abstract method to be overridden by the subclass. It shoud return str indicating its name.

static is_trainable()

Abstract method to be overridden by the subclass. It shoud return bool indicating if it is trainable.

training: bool
static uses_support()

Abstract method to be overridden by the subclass. It shoud return bool indicating if it uses support inputs (sparse matrices).

Module contents