deepxde.nn.activations module


Returns function.


identifier – Function or string (ELU, GELU, ReLU, SELU, Sigmoid, SiLU, sin, Swish, tanh).


Function corresponding to the input string or input function.

deepxde.nn.activations.layer_wise_locally_adaptive(activation, n=1)[source]

Layer-wise locally adaptive activation functions (L-LAAF).


To define a L-LAAF ReLU with the scaling factor n = 10:

n = 10
activation = f"LAAF-{n} relu"  # "LAAF-10 relu"


A. D. Jagtap, K. Kawaguchi, & G. E. Karniadakis. Locally adaptive activation functions with slope recovery for deep and physics-informed neural networks. Proceedings of the Royal Society A, 476(2239), 20200334, 2020.


deepxde.nn.initializers module

class deepxde.nn.initializers.VarianceScalingStacked(scale=1.0, mode='fan_in', distribution='truncated_normal', seed=None)[source]

Bases: object

Initializer capable of adapting its scale to the shape of weights tensors.

With distribution=”truncated_normal” or “untruncated_normal”, samples are drawn from a truncated/untruncated normal distribution with a mean of zero and a standard deviation (after truncation, if used) stddev = sqrt(scale / n) where n is:

  • number of input units in the weight tensor, if mode = “fan_in”

  • number of output units, if mode = “fan_out”

  • average of the numbers of input and output units, if mode = “fan_avg”

With distribution=”uniform”, samples are drawn from a uniform distribution within [-limit, limit], with limit = sqrt(3 * scale / n).

  • scale – Scaling factor (positive float).

  • mode – One of “fan_in”, “fan_out”, “fan_avg”.

  • distribution – Random distribution to use. One of “normal”, “uniform”.

  • seed – A Python integer. Used to create random seeds. See tf.set_random_seed for behavior.

  • dtype – Default data type, used if no dtype argument is provided when calling the initializer. Only floating point types are supported.


ValueError – In case of an invalid value for the “scale”, mode” or “distribution” arguments.


Retrieve an initializer by the identifier.


identifier – String that contains the initializer name or an initializer function.


Initializer instance base on the input identifier.

deepxde.nn.regularizers module