Package: fast-neptune
fast-neptuneQuickly track your Jupyter Notebook experiments with NeptuneMLfast-neptuneis a library that helps you quickly record all the information you need to launch your experiments, when you are using Jupyter Notebooks. Reproducibility has become a crucial issue in Machine Learning, not only for research, but also for real world applications, where we want to have robust results, and track every set of parameters tested, along with their results.fast-neptunespirit is highly inspired fromnbdevin the user experience, so it is recommended to have a look first at it.Furthermore,fast-neptuneis built upon the solutionneptune-mlwhich allows users to quickly record on a public or private repository. Following thequick introductionis a plus to understandfast-neptune, but as we will see it's quite intuitive.Installfast-neptuneis available on pypi so you can simply run :pip install fast-neptuneHow to usefast-neptunehas implemend several features to help you when you run ML experiments.
These include :metadata about the machine where the code is run, including OS, and OS versionrequirements of the notebook where the experiments are runparameters used during the experience, which means the names of the values of the variables you want to trackcode you used during the run that you want to recordNote that code and parameters are not mandatorily tracked, while the two former are, though the whole purpose of this library is to facilitate the tracking of parameters and code.MetadataMetadata is tracked about the requirements used and information about the Python version and OS used.They are added automatically when an experiment is created, through the functionsget_metadataandcreate_requirements.PropertyProperties refer to variables you want to record.To record properties, simply add#propertyto each cell containing the variables you want to record.Note : if one variable in a property is a file encapsulated in aPathobject, it is automatically tracked, and this file will be sent to NeptuneML. You can disable this option when creating the experiment.CodeCode cells can also be tracked.To do so, simply add#codeto each cell you want to record. You have the possibility to specify under what name the cell code will be registered. By default, all cells with#codewill be added chronogically to the file "main.py", but if you can put them in specific files by adding the name of the module you want them to be put in.Example : add#code dataloading.pyto the cells that take care of the data loading.Example with fastai vision to train a MNIST classifierTo understand more how all of this fit in, we will follow a simple example, using fastai library.First we will log in using NeptuneML# Neptune loginfromneptune.sessionsimportSessionimportgetpass# First we get the tokenapi_token=getpass.getpass("Please enter your NeptuneML API token : ")session=Session(api_token=api_token)# Then we enter user name and projectuser_name="danywin"project_name="fast-neptune"project=session.get_project(project_qualified_name=f'{user_name}/{project_name}')Please enter your NeptuneML API token : 


WARNING: Instantiating Session without specifying a backend is deprecated and will be removed in future versions. For current behaviour use `neptune.init(...)` or `Session.with_default_backend(...)
WARNING: It is not secure to place API token in your source code. You should treat it as a password to your account. It is strongly recommended to use NEPTUNE_API_TOKEN environment variable instead. Remember not to upload source file with API token to any public repository.Now we will start usingfast-neptune.First we will record the code used to load the data and learner. To do so, we simply add#codeto the cell used to load the data.fromfast_neptune.coreimport*#code dataloading.pyfromfastai.visionimport*path=untar_data(URLs.MNIST_SAMPLE)data=ImageDataBunch.from_folder(path)learn=cnn_learner(data,models.resnet18,metrics=accuracy)Then we want to keep track of the number of epochs during training, and the learning rate we used. To do so we add#propertyto the cell we want to track.#propertyn_epoch=1lr=1e-2Finally we usefast_experimentto create our experiment. Note that you must pass it the name of the notebook you are using for your experiments, and the global variables you are currently using to record each variable in the properties cells.Here we will create an experiment, then record the validation accuracy.#codenb_name="index.ipynb"globs=globals()withfast_experiment(project,nb_name,globs)asexp:learn.fit_one_cycle(n_epoch,lr)pred,y=learn.get_preds()score=accuracy(pred,y).item()exp.send_metric("valid_accuracy",score)https://ui.neptune.ai/danywin/fast-neptune/e/FAS1-18epochtrain_lossvalid_lossaccuracytime00.0525040.0141530.99460300:04Now if we go on the link provided by NeptuneML we can have a closer look at this experiment :Here we can see the parameters that were registered, including epoch, learning rate, OS, and Python version.In the source code tab, we can have a look at the bits of code we registered, here the dataloading.In the artifacts we also have the modules used in this notebook with their version :Finally, we logged the validation accuracy, which can be found in the Logs tab :