/ examples / pytorch / torchscript / MNIST / README.md
README.md
 1  ## MNIST example with MLflow
 2  
 3  This example demonstrates training of MNIST handwritten recognition model and logging it as torch scripted model.
 4  `mlflow.pytorch.log_model()` is used to log the scripted model to MLflow and `mlflow.pytorch.load_model()` to load it from MLflow
 5  
 6  ### Code related to MLflow:
 7  
 8  This will log the TorchScripted model into MLflow and load the logged model.
 9  
10  ## Setting Tracking URI
11  
12  MLflow tracking URI can be set using the environment variable `MLFLOW_TRACKING_URI`
13  
14  Example: `export MLFLOW_TRACKING_URI=http://localhost:5000/`
15  
16  For more details - https://mlflow.org/docs/latest/tracking.html#where-runs-are-recorded
17  
18  ### Running the code
19  
20  To run the example via MLflow, navigate to the `mlflow/examples/pytorch/torchscript/MNIST` directory and run the command
21  
22  ```
23  mlflow run .
24  ```
25  
26  This will run `mnist_torchscript.py` with the default set of parameters such as `--max_epochs=5`. You can see the default value in the `MLproject` file.
27  
28  In order to run the file with custom parameters, run the command
29  
30  ```
31  mlflow run . -P epochs=X
32  ```
33  
34  where `X` is your desired value for `epochs`.
35  
36  If you have the required modules for the file and would like to skip the creation of a conda environment, add the argument `--env-manager=local`.
37  
38  ```
39  mlflow run . --env-manager=local
40  ```
41  
42  Once the code is finished executing, you can view the run's metrics, parameters, and details by running the command
43  
44  ```
45  mlflow server
46  ```
47  
48  and navigating to [http://localhost:5000](http://localhost:5000).
49  
50  For more information on MLflow tracking, click [here](https://www.mlflow.org/docs/latest/tracking.html#mlflow-tracking) to view documentation.