Scientific ML Studio
Learn/ Studio Tour/ 3.4
3.4 · The blocks, one at a time

Build the network

The Network block is the unknown function. Choose its depth, width and activation, optionally lift the inputs with Fourier features, and draw it to check.

The Network block is the trial function $u_\theta$: a feed-forward neural network that takes the coordinates and returns the unknown field. If neural networks are new to you, chapter 2 of the textbook builds one from scratch.

Wiring

The block has one input, Coords, and one output, Network.

  • Connect the Domain's Coords to the Network's Coords. The network's input width then follows the Domain: one input for a line, two for a rectangle or circle, and one more if time is on.
  • Connect the Network's output to the Loss block's Network input.

If you forget the Coords wire, the Graph check tells you: The Network block has no Coords wire from the Domain, so its input width is assumed to be N. The script will still be made, but it will not follow later changes to the geometry.

The settings

Field Default What it does
Network outputs 1 How many numbers the network returns. One per unknown field. Leave at 1 for a single field
Hidden layers 40, 40, 40, 40 A comma-separated list of widths, one number per hidden layer. 40, 40, 40, 40 is four hidden layers of 40 neurons
Activation tanh The nonlinearity between layers: tanh, sin (SIREN), GELU, SiLU / swish, or Softplus
Initialisation Xavier / Glorot How the starting weights are drawn: Xavier, Kaiming / He, SIREN, or PyTorch default

A few practical notes.

The shape. 40, 40, 40, 40 with one input and one output has 5,041 parameters (5,081 with two inputs). That is plenty for the smooth problems in this tour. The list accepts commas or semicolons, widths up to 4096, and up to 32 layers; entries that are not positive whole numbers are skipped, and if nothing can be read the Lab falls back to four layers of 40 and tells you.

The activation. PDE residuals contain derivatives of the network, so the activation must be smooth. tanh is the standard choice for PINNs. A ReLU network would have a second derivative of zero almost everywhere, so a second-order PDE would see nothing; that is why ReLU is not on the list. sin (SIREN) suits solutions that oscillate rapidly, but it must be paired with the SIREN initialisation to train reliably. The Lab does not force the pair, so match them yourself.

The initialisation. Xavier suits tanh. Kaiming suits ReLU-family activations. SIREN is required with sin. When in doubt, leave the default.

Input scaling. The generated network scales the coordinates to the range $[-1, 1]$ using the Domain's bounds before the first layer, whether or not you use an Encoding block. You do not need to normalise anything yourself.

Draw it to check

Press Plot network diagram. The panel draws the network as columns of neurons: the input width, each hidden layer, and the output width. A layer wider than nine neurons is drawn as a sample of nine with its true width printed underneath. The button changes to Hide diagram. This is the architecture the generated script will build, not a picture of a trained network.

Your screenshot · the Plot network diagram preview for a 2-input network with four hidden layers.

Optional: the Encoding block

An Encoding block sits between the Domain and the Network and changes how the coordinates enter the network. Wire it as Domain Coords → Encoding Coords, then Encoding Encoded → Network Coords.

Currently the only mapping is Fourier features. It projects each coordinate onto a set of random frequencies and feeds the sines and cosines of those to the network. It exists for solutions with fine, fast variation, which a plain network learns slowly.

Field Default Meaning
Fourier features 32 How many random frequencies. The network's first layer receives twice this many numbers (a sine and a cosine each), so 32 features means 64 inputs
Fourier sigma 1.0 The scale of the random frequencies. Larger reaches high frequencies sooner but can make training noisier. Start near 1 and raise it only if you know the solution oscillates quickly
Normalise inputs on Keep on

Custom mapping is on the menu but marked coming soon and cannot be chosen. If an Encoding block is on the canvas but nothing wires its output into a Network, it has no effect, and the Graph check says so. A smooth problem such as Poisson needs no Encoding block at all; leave it out.

Next: balancing the loss.