Weights and Biases
What is Weights and Biases
For probably 99% of all neural networks, a hyperparameter search is needed. Things like the number of neurons, then number of layers, the optimizer, the regularization etc. all need to be varied if you wish to get the best performing model. This can quickly become cumbersome (given how quickly permuations grow).
One way of hangling a hyperparameter search is to use a program called Weights and Biases. In order to get started with W&B, follow this document. This quickstart was written by Dr. Monique Shotande, so reach out to her if you have questions!
Quickstart for W&B on Schooner
- Create an account and install W&B
Sign up for free: https://wandb.ai/site and then login
- Install the wandb into a Python 3 environment
pip install wandb
or
mamba install -c conda-forge wandb
- From the command line, login to wandb
You’ll need your API key to login via the CLI
wandb login
- Start a run and track hyperparameters
Initialize a W&B Run object with
wandb.init()and pass a dictionary to the config parameter with key-value pairs of hyperparameter names and values:
run = wandb.init( # Set the project where this run will be logged project="my-awesome-project", # Track hyperparameters and run metadata config={"learning_rate": 0.01, "epochs": 10,})
Use the WandbMetricsLogger() callback to automatically track the loss and metrics
# Modern lightweight callback # Tracks the loss and metrics # note: wandb callbacks can only be initialized after # wandb.init() metrics_callback = WandbMetricsLogger() # Train model history = model.fit(x_train, y_train, epochs=config['epochs'], callbacks=[metrics_callback])
Go to your wandb home to view the details of the experiment and watch run in real-time
You can find the specific urls for the unique runs in the error field generated by slurm jobs
Additional Resources:
AI2ES Coding Standards: Documentation Standards by Jay Rothenberger
Using wandb with Keras Tuners: