MLP¶
Fully-connected network for low-dimensional PDE problems.
mlp
¶
Multi-Layer Perceptron for FlowPDE.
Fully-connected network for low-dimensional PDE problems where convolutional structure is not beneficial.
MLP
¶
Bases: Module
Multi-Layer Perceptron for flow matching.
A fully-connected neural network that predicts velocity fields for continuous normalizing flows. Suitable for low-dimensional problems or when spatial structure is not important.
Architecture
Input Proj → [Residual Block × num_layers] → Output Proj
Features
- Fourier time embeddings (sinusoidal features)
- Residual connections in middle layers
- Flexible hidden dimension and depth
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input_dim
|
int
|
Dimension of input/output space (x and the velocity output) |
required |
condition_dim
|
Optional[int]
|
Dimension of the condition f. Defaults to input_dim when using ConcatConditioner (the most common case). |
None
|
hidden_dim
|
int
|
Number of hidden units in each layer (default: 128) |
128
|
num_layers
|
int
|
Number of residual blocks (default: 4) |
4
|
activation
|
str
|
Activation function name (default: 'swish') |
'swish'
|
dropout
|
float
|
Dropout probability (default: 0.0) |
0.0
|
conditioner
|
Optional[BaseConditioner]
|
Conditioning mechanism. Defaults to ConcatConditioner, which concatenates f to x before the first linear layer. |
None
|
Source code in flowpde/models/mlp.py
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 | |
forward(x, f, t)
¶
Predict velocity field for flow matching.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
Tensor
|
State x_t ∈ R^d, shape (B, d) or (B, *spatial_shape) |
required |
f
|
Tensor
|
Condition, shape (B, d) or (B, *spatial_shape) |
required |
t
|
Tensor
|
Time t ∈ [0, 1], shape (B,) or (B, 1) |
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
Velocity field v(x, f, t) ∈ R^d, same shape as input x |