Examples

Time Sequence Prediction

This example will take you through training your own time sequence prediction model using Unweave. By the end, you'll have used Unweave to:

  • Launch a zepl to train a time sequence prediction model and generate predictions,
  • Download the prediction plots from your uwstore back to your local laptop

Before we begin, you should follow the Getting Started guide to install the Unweave CLI and login for the first time.

Preparing your project

We're first going to clone the starters repository from the Unweave Github account and change into the time-sequence-prediction starter template directory:

git clone https://github.com/unweave/starters.git
cd starters/time-sequence-prediction

We then need to initialize this directory using the unweave init command. This will create a new project, which we'll default the name to time-sequence-prediction and link it to the time-sequence-prediction directory on our local machine.

โฏ unweave init
? Enter project name [time-sequence-prediction]:
Created project time-sequence-prediction
Path:    	/Users/markwinter/Code/starters/time-sequence-prediction
Project: 	time-sequence-prediction

Train Your Model

Now that we have the project setup, it's time to launch a zepl to train our time sequence model. You can do this by pre-pending unweave in-front of the command you would normally run to execute your python script. This will build the ZeplContext from your current directory, assign a serverless compute node, and run the zepl using the command you provide - in this case python train.py.

The train.py training script generates a sine wave and then uses it to train the model for 3 steps . After a training step it makes a prediction for future values and saves them to a plot in a PDF file in the ./uwstore/output directory. Unweave will automatically sync anything written to the ./uwstore/output directory back to the uwstore once the zepl exits.

โฏ unweave python train.py
Created zepl "wooden-dish-most-sea" with ID "52bf79f0-643d-4d6c-b4e6-6ecbef3c9315"
Starting zepl
Press Ctrl+C to cancel the zepl
Press Ctrl+D to detach
๐Ÿ”„ Initializing serverless compute node
โœ… Compute node assigned to zepl
๐Ÿ”„ Syncing Unweave Store
๐Ÿ”„ Building environment
๐Ÿš€ Zepl running. Fetching logs ...
STEP:  0
loss: 0.5023738120466186
loss: 0.4985663932454724
loss: 0.479011960201462
loss: 0.44633490395179287
loss: 0.3540631027261268
loss: 0.20507018018165285
..
๐Ÿงน Cleaning up
โœ… Zepl complete

The train.py script has one argument you can use to adjust the number of steps to train. You can pass in arguments to your script by appending a -- after the script followed by the desired arguments:

unweave python train.py -- --steps=5

Once the Python script exits, we can list the uwstore to view the saved PDF files containing the prediction plots that were saved to ./uwstore/output during the script execution.

โฏ unweave store list 
2022-09-01 20:06:03 +0900 KST	25 kB	output/52bf79f0-643d-4d6c-b4e6-6ecbef3c9315/predict0.pdf
2022-09-01 20:06:03 +0900 KST	40 kB	output/52bf79f0-643d-4d6c-b4e6-6ecbef3c9315/predict1.pdf
2022-09-01 20:06:03 +0900 KST	28 kB	output/52bf79f0-643d-4d6c-b4e6-6ecbef3c9315/predict2.pdf
2022-09-01 20:06:03 +0900 KST	40 kB	output/52bf79f0-643d-4d6c-b4e6-6ecbef3c9315/predict3.pdf
2022-09-01 20:06:03 +0900 KST	38 kB	output/52bf79f0-643d-4d6c-b4e6-6ecbef3c9315/predict4.pdf

If you want to download objects from the uwstore back to your local computer, you can use the unweave store download command. Giving a directory path to the command will download everything in the directory.

$ unweave store download output/52bf79f0-643d-4d6c-b4e6-6ecbef3c9315
predict0.pdf saved to ./uwstore/output/52bf79f0-643d-4d6c-b4e6-6ecbef3c9315/predict0.pdf
predict1.pdf saved to ./uwstore/output/52bf79f0-643d-4d6c-b4e6-6ecbef3c9315/predict1.pdf
predict2.pdf saved to ./uwstore/output/52bf79f0-643d-4d6c-b4e6-6ecbef3c9315/predict2.pdf
predict3.pdf saved to ./uwstore/output/52bf79f0-643d-4d6c-b4e6-6ecbef3c9315/predict3.pdf
predict4.pdf saved to ./uwstore/output/52bf79f0-643d-4d6c-b4e6-6ecbef3c9315/predict4.pdf
Previous
MNIST