Exporting models to `ONNX` format

Learner.to_onnx[source]

Learner.to_onnx(x:Learner, fname='export', path=Path('.'))

Export model to ONNX format

Currently supports single-output models. See an example usage below:

from fastai.tabular.all import *
path = untar_data(URLs.ADULT_SAMPLE)
df = pd.read_csv(path/'adult.csv')
splits = RandomSplitter()(range_of(df))
cat_names = ['workclass', 'education', 'marital-status', 'occupation', 'relationship', 'race']
cont_names = ['age', 'fnlwgt', 'education-num']
procs = [Categorify, FillMissing, Normalize]
y_names = 'salary'
dls = TabularPandas(df, procs=procs, cat_names=cat_names, cont_names=cont_names,
                   y_names=y_names, splits=splits).dataloaders()
learn = tabular_learner(dls, layers=[200,100])
learn.to_onnx('tabular')

class fastONNX[source]

fastONNX(fn)

ONNX wrapper for Learner