npu

npu.api(token)

Use this function to get access to the API, providing your token. All subsequents API calls will use this token.

Parameters

token (str) – Token from dashboard

npu.compile(model, input_shape, library='', model_label='', asynchronous=False)

Use this to upload and compile your model. Compatible frameworks are:

  • Pytorch

  • Tensorflow 2

  • Mxnet

Parameters
  • model (Object from framework or filename(str) to the model. Tensorflow + mxnet models must be tarred if using filenames.) – Original model to compile.

  • input_shape (List) – Input shape of model

  • library (str (pytorch, tf, mxnet)) – Library used

  • model_label (str, optional) – Label for model

  • asynchronous (bool, optional.) – If call should run async or not. Default=`False`

Returns

compiled model.

npu.predict(model, data, asynchronous=False, callback=None)

Perform a predict using a model. Default behaviour is synchronous.

Parameters
  • model (From npu.compile() or npu.train(). Id (str) or global npu.vision.models.Model can be used.) – Model used to predict

  • data (numpy array) – Data to be used for prediction

  • asynchronous (bool, optional.) – If call should run async or not. Default=`False`. If you want to get the result back explicitly, call “get_result()” on returned value.

  • callback (function) – runs a callback function on results (asynchronous)

npu.train(model, train_data, val_data, batch_size=32, epochs=1, optim={'opt_args': {'lr': 0.001, 'momentum': 0.9}, 'optimiser': 'SGD'}, loss='SparseCrossEntropyLoss', asynchronous=False, callback=None)

Perform a train using a model. Default behaviour is synchronous.

Parameters
  • model (From npu.compile() or npu.train(). Id (str) or global npu.vision.models.Model can be used.) – Model used to predict

  • train_data (numpy array) – Training data in format of (x, y)

  • val_data (numpy array) – Validation data in format of (x, y)

  • batch_size (int, optional) – Batch size for training. Default=`32`

  • epochs (int, optional) – Epoch cycles for training. Default=`1`

  • optim (npu.optim()) – Optimiser to use

  • loss – Loss function to use

  • asynchronous (bool, optional.) – If call should run async or not. Default=`False`. If you want to get the result back explicitly, call “get_result()” on returned value.

  • callback (function) – runs a callback function on results (asynchronous)

npu.export(model, path='.')

Export a model to file. This will export it in the original format it is in. Global models will be exported as pytorch models.

param model

Model to export

type model

From npu.compile() or npu.train(). Id (str) or global npu.vision.models.Model can be used.

param path

Path to where the model is saved to. Default is “.”.

type path

str, optional