neon.backends.gen_backend(backend='mkl', rng_seed=None, datatype=<class 'numpy.float32'>, batch_size=0, stochastic_round=False, device_id=0, max_devices=4, compat_mode=None, deterministic_update=None, deterministic=None)[source]

Construct and return a backend instance of the appropriate type based on the arguments given. With no parameters, a single CPU core, float32 backend is returned.

  • backend (string, optional) – ‘cpu’, ‘mkl’ or ‘gpu’.
  • rng_seed (numeric, optional) – Set this to a numeric value which can be used to seed the random number generator of the instantiated backend. Defaults to None, which doesn’t explicitly seed (so each run will be different)
  • datatype (dtype) – Default tensor data type. CPU backend supports np.float64, np.float32, and np.float16; GPU backend supports np.float32 and np.float16.
  • batch_size (int) – Set the size the data batches.
  • stochastic_round (int/bool, optional) – Set this to True or an integer to implent stochastic rounding. If this is False rounding will be to nearest. If True will perform stochastic rounding using default bit width. If set to an integer will round to that number of bits. Only affects the gpu backend.
  • device_id (numeric, optional) – Set this to a numeric value which can be used to select device on which to run the process
  • max_devices (int, optional) – For use with multi-GPU backend only. Controls the maximum number of GPUs to run on.
  • compat_mode (str, optional) – if this is set to ‘caffe’ then the conv and pooling layer output sizes will match that of caffe as will the dropout layer implementation
  • deterministic (bool, optional) – if set to true, all operations will be done deterministically.

newly constructed backend instance of the specifed type.

Return type:



  • Attempts to construct a GPU instance without a CUDA capable card or without nervanagpu package installed will cause the program to display an error message and exit.