xnn.gnn.models.gemnet.ScaleFactor#

class xnn.gnn.models.gemnet.ScaleFactor[source]#

Bases: Module

A constant factor that keeps the activation variance of a layer (paper section 6).

It multiplies the output y of a sum aggregation or a Hadamard / bilinear product; GemNet.fit_scaling_factors() sets it so that the variance of y matches that of the layer input ref on data.

Variables:
  • scale_factor (Tensor) – The scalar factor (a buffer, 1 until fitted).

  • fitting (bool) – Whether forward() accumulates the variances of its inputs.

forward(ref, y)[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.

Parameters:
Return type:

Tensor