EXAMPLE 01
Force the reference backend.
PYTHON
from mlbricks import ESA
layer = ESA(embd=384, head=6, backend="pytorch")EXAMPLE 02
Switch backend policy after construction.
PYTHON
layer.set_backend("native")
layer.set_backend("pytorch")
layer.set_backend("auto")EXAMPLE 03
Train an ESA model with the common trainer.
PYTHON
import mlbricks as mlb
trainer = mlb.Trainer(
model,
optimizer="adamw",
lr=3e-4,
checkpoint_dir="checkpoints",
)
trainer.fit(train_loader, steps=10_000)EXAMPLE 04
Inspect execution before serving.
PYTHON
from mlbricks import backend_report, build_execution_plan
print(backend_report(model))
print(build_execution_plan(model))