- tf_leapnet_DEFAULT β TensorFlow LeapNet Model
- Architecture: LeapNet (Latent Encoding of Atypical Perturbations) β encoder + main network + decoder, specialised for handling topology changes via a dedicated tau encoding path
Framework: TensorFlow / Keras
Key difference from tf_fc: LeapNet explicitly separates the topology input (attr_tau) from the physical inputs (attr_x), making it better at generalising to unseen topologies. - Folder contents
- Installation
- Usage
- Input / Output
- Architecture: LeapNet (Latent Encoding of Atypical Perturbations) β encoder + main network + decoder, specialised for handling topology changes via a dedicated tau encoding path
tf_leapnet_DEFAULT β TensorFlow LeapNet Model
Benchmark1 surrogate model for power grid current flow prediction.
Trained on the l2rpn_case14_sandbox environment to predict line currents (a_or, a_ex) from grid injections and topology.
Architecture: LeapNet (Latent Encoding of Atypical Perturbations) β encoder + main network + decoder, specialised for handling topology changes via a dedicated tau encoding path
Framework: TensorFlow / Keras
Key difference from tf_fc: LeapNet explicitly separates the topology input (attr_tau) from the physical inputs (attr_x), making it better at generalising to unseen topologies.
Folder contents
tf_leapnet/
βββ weights.h5 β trained Keras weights (legacy naming)
βββ config.json β hyperparameters
βββ metadata.json β input/output sizes
βββ scaler_params.json β normalisation statistics
βββ losses.json β training history
βββ tf_leapnet.ini β simulator configuration
βββ l2rpn_case14_sandbox.ini β benchmark configuration
The weight file is named
weights.h5(without themodel.prefix) because this model was saved with an older version of Keras. The restore code handles this automatically.
Installation
pip install leap-net==0.0.5
leap-netis a separate dependency required only for LeapNet. Without it, the import will fail silently with anImportError.
Usage
import pathlib
import numpy as np
from lips.augmented_simulators.tensorflow_models.powergrid import LeapNet
from lips.dataset.scaler import StandardScaler
from lips.dataset.powergridDataSet import PowerGridDataSet
MODEL_DIR = pathlib.Path("path/to/tf_leapnet_DEFAULT")
# Instantiate and restore
# name="tf_leapnet" + sim_config_name="DEFAULT" β model.name = "tf_leapnet_DEFAULT"
# restore() looks for MODEL_DIR.parent / "tf_leapnet_DEFAULT"
model = LeapNet(
name="tf_leapnet",
sim_config_path=MODEL_DIR / "tf_leapnet.ini",
sim_config_name="DEFAULT",
bench_config_path=MODEL_DIR / "l2rpn_case14_sandbox.ini",
bench_config_name="Benchmark1",
scaler=StandardScaler,
)
model.restore(MODEL_DIR.parent)
# Prepare input data
N = 100 # number of samples
dataset = PowerGridDataSet(
name="my_data",
config_path=MODEL_DIR / "l2rpn_case14_sandbox.ini",
config_name="Benchmark1",
)
dataset.data = {
"prod_p": np.random.rand(N, 6).astype(np.float32), # MW
"prod_v": np.random.rand(N, 6).astype(np.float32), # per-unit voltage
"load_p": np.random.rand(N, 11).astype(np.float32), # MW
"load_q": np.random.rand(N, 11).astype(np.float32), # MVAr
"line_status": np.ones((N, 20), dtype=bool), # True = connected
"topo_vect": np.ones((N, 57), dtype=np.int32), # bus assignments (1 or 2)
# Dummy targets β required by the data pipeline even at inference time
"a_or": np.zeros((N, 20), dtype=np.float32),
"a_ex": np.zeros((N, 20), dtype=np.float32),
}
# Run inference
predictions = model.predict(dataset)
print(predictions["a_or"].shape) # (N, 20) β current at origin end of each line (A)
print(predictions["a_ex"].shape) # (N, 20) β current at extremity end of each line (A)
Input / Output
Inputs β 111 features total
| Feature | Shape | Unit | Description |
|---|---|---|---|
prod_p |
(N, 6) | MW | Active power output per generator |
prod_v |
(N, 6) | p.u. | Voltage setpoint per generator |
load_p |
(N, 11) | MW | Active power demand per load |
load_q |
(N, 11) | MVAr | Reactive power demand per load |
line_status |
(N, 20) | bool | Line connection status (1=on, 0=off) |
topo_vect |
(N, 57) | int | Bus assignment per element (1 or 2) |
Internally, LeapNet routes
line_statusandtopo_vectthrough a separate tau encoding path. This is handled automatically β your input dict format is the same as tf_fc.
Outputs β 40 values total
| Feature | Shape | Unit | Description |
|---|---|---|---|
a_or |
(N, 20) | A | Current at the origin end of each line |
a_ex |
(N, 20) | A | Current at the extremity end of each line |
- Downloads last month
- 11
Inference Providers NEW
This model isn't deployed by any Inference Provider. π Ask for provider support