Package: gradient-sdk
Gradient ML SDKThis is an SDK for performing Machine Learning with Gradientº, it can be installed in addition togradient-cli.RequirementsThis SDK requires Python 3.5+.To install it, run:pipinstallgradient-sdkUsageMultinode Helper FunctionsMultinode GRPC TensorflowSet the TF_CONFIG environment variableFor multi-worker training, you need to set theTF_CONFIGenvironment variable for each binary running in your cluster. Set the value ofTF_CONFIGto a JSON string that specifies each task within the cluster, including each task's address and role within the cluster. We've provided a Kubernetes template in the tensorflow/ecosystem repo which setsTF_CONFIGfor your training tasks.get_tf_config()Function to set value ofTF_CONFIGwhen run on machines within Paperspace infrastructure.It can raise aConfigErrorexception with message if there's a problem with its configuration in a particular machine.Usage example:fromgradient_sdkimportget_tf_configget_tf_config()Hyperparameter TuningCurrently, Gradientº only supportsHyperoptfor Hyperparameter Tuning.hyper_tune()Function to run hyperparameter tuning.It accepts the following arguments:train_modelUser model to tune.hparam_defUser definition (scope) of search space.
To set this value, refer tohyperopt documentation.algoSearch algorithm.Default:tpe.suggest(from hyperopt).max_ecalsMaximum number of function evaluations to allow before returning.Default:25.funcFunction to be run by hyper tune.Default:fmin(from hyperopt).Do not change this value if you do not know what you are doing!It returns a dict with information about the tuning process.It can raise aConfigErrorexception with message if there's no connection to MongoDB.Note:You do not need to worry about setting your MongoDB version; it will be set within Paperspace infrastructure for hyperparameter tuning.Usage example:fromgradient_sdkimporthyper_tune# Prepare model and search scope# minimal versionargmin1=hyper_tune(model,scope)# pass more argumentsargmin2=hyper_tune(model,scope,algo=tpe.suggest,max_evals=100)Utility Functionsget_mongo_conn_str()Function to check and construct MongoDB connection string.It returns a connection string to MongoDB.It can raise aConfigErrorexception with message if there's a problem with any values used to prepare the MongoDB connection string.Usage example:fromgradient_sdkimportget_mongo_conn_strconn_str=get_mongo_conn_str()data_dir()Function to retrieve path to job space.Usage example:fromgradient_sdkimportdata_dirjob_space=data_dir()model_dir()Function to retrieve path to model space.Usage example:fromgradient_sdkimportmodel_dirmodel_path=model_dir(model_name)export_dir()Function to retrieve path for model export.Usage example:fromgradient_sdkimportexport_dirmodel_path=export_dir(model_name)worker_hosts()Function to retrieve information about worker hosts.Usage example:fromgradient_sdkimportworker_hostsmodel_path=worker_hosts()ps_hosts()Function to retrieve information about Paperspace hosts.Usage example:fromgradient_sdkimportps_hostsmodel_path=ps_hosts()task_index()Function to retrieve information about task index.Usage example:fromgradient_sdkimporttask_indexmodel_path=task_index()job_name()Function to retrieve information about job name.Usage example:fromgradient_sdkimportjob_namemodel_path=job_name()