diff --git a/content/guides/integrations/add-wandb-to-any-library.md b/content/guides/integrations/add-wandb-to-any-library.md index 3fcd377b5..83827f576 100644 --- a/content/guides/integrations/add-wandb-to-any-library.md +++ b/content/guides/integrations/add-wandb-to-any-library.md @@ -76,46 +76,70 @@ dev = [ ### User Login -There are a few ways for your users to log in to W&B: +#### Create an API key + +An API key authenticates a client or machine to W&B. You can generate an API key from your user profile. + +{{% alert %}} +For a more streamlined approach, you can generate an API key by going directly to [https://wandb.ai/authorize](https://wandb.ai/authorize). Copy the displayed API key and save it in a secure location such as a password manager. +{{% /alert %}} + +1. Click your user profile icon in the upper right corner. +1. Select **User Settings**, then scroll to the **API Keys** section. +1. Click **Reveal**. Copy the displayed API key. To hide the API key, reload the page. + +#### Install the `wandb` library and log in + +To install the `wandb` library locally and log in: {{< tabpane text=true >}} +{{% tab header="Command Line" value="cli" %}} -{{% tab header="Bash" value="bash" %}} -Log into W&B with a bash command in a terminal: +1. Set the `WANDB_API_KEY` [environment variable]({{< relref "/guides/models/track/environment-variables.md" >}}) to your API key. + + ```bash + export WANDB_API_KEY= + ``` + +1. Install the `wandb` library and log in. + + + + ```shell + pip install wandb + + wandb login + ``` -```bash -wandb login $MY_WANDB_KEY -``` {{% /tab %}} -{{% tab header="Notebook" value="notebook" %}} -If they're in a Jupyter or Colab notebook, log into W&B like so: +{{% tab header="Python" value="python" %}} +```bash +pip install wandb +``` ```python import wandb wandb.login() ``` -{{% /tab %}} -{{% tab header="Environment Variable" value="environment" %}} -Set a [W&B environment variable]({{< relref "/guides/models/track/environment-variables.md" >}}) for the API key: +{{% /tab %}} -```bash -export WANDB_API_KEY=$YOUR_API_KEY -``` +{{% tab header="Python notebook" value="python-notebook" %}} -or +```notebook +!pip install wandb -```python -os.environ['WANDB_API_KEY'] = "abc123..." +import wandb +wandb.login() ``` -{{% /tab %}} +{{% /tab %}} {{< /tabpane >}} If a user is using wandb for the first time without following any of the steps mentioned above, they will automatically be prompted to log in when your script calls `wandb.init`. -### Starting A wandb Run +### Start a run A W&B Run is a unit of computation logged by W&B. Typically, you associate a single W&B Run per training experiment. @@ -211,8 +235,7 @@ wandb offline {{< /tabpane >}} -### Defining A wandb Run Config - +### Define a run config With a `wandb` run config, you can provide metadata about your model, dataset, and so on when you create a W&B Run. You can use this information to compare different experiments and quickly understand the main differences. {{< img src="/images/integrations/integrations_add_any_lib_runs_page.png" alt="W&B Runs table" >}} @@ -230,8 +253,7 @@ config = {"batch_size": 32, ...} wandb.init(..., config=config) ``` -#### Updating The wandb config - +#### Update the run config Use `wandb.config.update` to update the config. Updating your configuration dictionary is useful when parameters are obtained after the dictionary was defined. For example, you might want to add a model’s parameters after the model is instantiated. ```python @@ -240,9 +262,9 @@ wandb.config.update({"model_parameters": 3500}) For more information on how to define a config file, see [Configure Experiments with wandb.config]({{< relref "/guides/models/track/config" >}}). -### Logging To W&B +### Log to W&B -#### Log Metrics +#### Log metrics Create a dictionary where the key value is the name of the metric. Pass this dictionary object to [`wandb.log`]({{< relref "/guides/models/track/log" >}}): @@ -271,7 +293,7 @@ wandb.log(metrics) For more on `wandb.log`, see [Log Data with wandb.log]({{< relref "/guides/models/track/log" >}}). -#### Preventing x-axis Misalignments +#### Prevent x-axis misalignments Sometimes you might need to perform multiple calls to `wandb.log` for the same training step. The wandb SDK has its own internal step counter that is incremented every time a `wandb.log` call is made. This means that there is a possibility that the wandb log counter is not aligned with the training step in your training loop. @@ -299,7 +321,7 @@ for step, (input, ground_truth) in enumerate(data): If you do not have access to the independent step variable, for example "global_step" is not available during your validation loop, the previously logged value for "global_step" is automatically used by wandb. In this case, ensure you log an initial value for the metric so it has been defined when it’s needed. -#### Log Images, Tables, Text, Audio and More +#### Log images, tables, audio, and more In addition to metrics, you can log plots, histograms, tables, text, and media such as images, videos, audios, 3D, and more. @@ -312,7 +334,7 @@ Some considerations when logging data include: Refer to [Log Data with wandb.log]({{< relref "/guides/models/track/log" >}}) for a full guide on logging media, objects, plots, and more. -### Distributed Training +### Distributed training For frameworks supporting distributed environments, you can adapt any of the following workflows: @@ -321,7 +343,7 @@ For frameworks supporting distributed environments, you can adapt any of the fol See [Log Distributed Training Experiments]({{< relref "/guides/models/track/log/distributed-training.md" >}}) for more details. -### Logging Model Checkpoints And More +### Log model checkpoints and more If your framework uses or produces models or datasets, you can log them for full traceability and have wandb automatically monitor your entire pipeline through W&B Artifacts. @@ -333,7 +355,7 @@ When using Artifacts, it might be useful but not necessary to let your users def * The path/reference of the artifact being used as input, if any. For example, `user/project/artifact`. * The frequency for logging Artifacts. -#### Log Model Checkpoints +#### Log model checkpoints You can log Model Checkpoints to W&B. It is useful to leverage the unique `wandb` Run ID to name output Model Checkpoints to differentiate them between Runs. You can also add useful metadata. In addition, you can also add aliases to each model as shown below: @@ -355,7 +377,7 @@ For information on how to create a custom alias, see [Create a Custom Alias]({{< You can log output Artifacts at any frequency (for example, every epoch, every 500 steps, and so on) and they are automatically versioned. -#### Log And Track Pre-trained Models Or Datasets +#### Log and track pre-trained models or datasets You can log artifacts that are used as inputs to your training such as pre-trained models or datasets. The following snippet demonstrates how to log an Artifact and add it as an input to the ongoing Run as shown in the graph above. @@ -365,7 +387,7 @@ artifact_input_data.add_file("flowers.npy") wandb.use_artifact(artifact_input_data) ``` -#### Download A W&B Artifact +#### Download an artifact You re-use an Artifact (dataset, model, etc.) and `wandb` will download a copy locally (and cache it): @@ -385,11 +407,11 @@ local_path = artifact.download() For more information, see [Download and Use Artifacts]({{< relref "/guides/core/artifacts/download-and-use-an-artifact" >}}). -### Hyper-parameter Tuning +### Tune hyper-parameters If your library would like to leverage W&B hyper-parameter tuning, [W&B Sweeps]({{< relref "/guides/models/sweeps/" >}}) can also be added to your library. -### Advanced Integrations +### Advanced integrations You can also see what an advanced W&B integrations look like in the following integrations. Note most integrations will not be as complex as these: diff --git a/content/guides/integrations/deepchem.md b/content/guides/integrations/deepchem.md index 3ff62c146..d1f587368 100644 --- a/content/guides/integrations/deepchem.md +++ b/content/guides/integrations/deepchem.md @@ -23,76 +23,104 @@ model.fit(…) Explore the Using [W&B with DeepChem: Molecular Graph Convolutional Networks](https://wandb.ai/kshen/deepchem_graphconv/reports/Using-W-B-with-DeepChem-Molecular-Graph-Convolutional-Networks--Vmlldzo4MzU5MDc?galleryTag=) article for an example charts generated using the W&B DeepChem integration. -If you'd rather dive straight into working code, check out this [**Google Colab**](https://colab.research.google.com/github/wandb/examples/blob/master/colabs/deepchem/W%26B_x_DeepChem.ipynb). +To dive straight into working code, check out this [**Google Colab**](https://colab.research.google.com/github/wandb/examples/blob/master/colabs/deepchem/W%26B_x_DeepChem.ipynb). ## Track experiments -Setup Weights & Biases for DeepChem models of type [KerasModel](https://deepchem.readthedocs.io/en/latest/api_reference/models.html#keras-models) or [TorchModel](https://deepchem.readthedocs.io/en/latest/api_reference/models.html#pytorch-models). +Set up W&B for DeepChem models of type [KerasModel](https://deepchem.readthedocs.io/en/latest/api_reference/models.html#keras-models) or [TorchModel](https://deepchem.readthedocs.io/en/latest/api_reference/models.html#pytorch-models). -1. Install the `wandb` library and log in +### Sign up and create an API key - {{< tabpane text=true >}} +An API key authenticates your machine to W&B. You can generate an API key from your user profile. - {{% tab header="Command Line" value="cli" %}} +{{% alert %}} +For a more streamlined approach, you can generate an API key by going directly to [https://wandb.ai/authorize](https://wandb.ai/authorize). Copy the displayed API key and save it in a secure location such as a password manager. +{{% /alert %}} +1. Click your user profile icon in the upper right corner. +1. Select **User Settings**, then scroll to the **API Keys** section. +1. Click **Reveal**. Copy the displayed API key. To hide the API key, reload the page. + +### Install the `wandb` library and log in + +To install the `wandb` library locally and log in: + +{{< tabpane text=true >}} +{{% tab header="Command Line" value="cli" %}} + +1. Set the `WANDB_API_KEY` [environment variable]({{< relref "/guides/models/track/environment-variables.md" >}}) to your API key. + + ```bash + export WANDB_API_KEY= ``` + +1. Install the `wandb` library and log in. + + + + ```shell pip install wandb + wandb login ``` - {{% /tab %}} +{{% /tab %}} - {{% tab header="Notebook" value="notebook" %}} +{{% tab header="Python" value="python" %}} - ```python - !pip install wandb +```bash +pip install wandb +``` +```python +import wandb +wandb.login() +``` - import wandb - wandb.login() - ``` +{{% /tab %}} - {{% /tab %}} +{{% tab header="Python notebook" value="python-notebook" %}} - {{< /tabpane >}} +```notebook +!pip install wandb -2. Initialize and configure WandbLogger +import wandb +wandb.login() +``` - ```python - from deepchem.models import WandbLogger +{{% /tab %}} - logger = WandbLogger(entity="my_entity", project="my_project") - ``` +{{< /tabpane >}} -3. Log your training and evaluation data to W&B +### Log your training and evaluation data to W&B - Training loss and evaluation metrics can be automatically logged to Weights & Biases. Optional evaluation can be enabled using the DeepChem [ValidationCallback](https://github.com/deepchem/deepchem/blob/master/deepchem/models/callbacks.py), the `WandbLogger` will detect ValidationCallback callback and log the metrics generated. +Training loss and evaluation metrics can be automatically logged to W&B. Optional evaluation can be enabled using the DeepChem [ValidationCallback](https://github.com/deepchem/deepchem/blob/master/deepchem/models/callbacks.py), the `WandbLogger` will detect ValidationCallback callback and log the metrics generated. - {{< tabpane text=true >}} +{{< tabpane text=true >}} - {{% tab header="TorchModel" value="torch" %}} +{{% tab header="TorchModel" value="torch" %}} - ```python - from deepchem.models import TorchModel, ValidationCallback +```python +from deepchem.models import TorchModel, ValidationCallback - vc = ValidationCallback(…) # optional - model = TorchModel(…, wandb_logger=logger) - model.fit(…, callbacks=[vc]) - logger.finish() - ``` +vc = ValidationCallback(…) # optional +model = TorchModel(…, wandb_logger=logger) +model.fit(…, callbacks=[vc]) +logger.finish() +``` - {{% /tab %}} +{{% /tab %}} - {{% tab header="KerasModel" value="keras" %}} +{{% tab header="KerasModel" value="keras" %}} - ```python - from deepchem.models import KerasModel, ValidationCallback +```python +from deepchem.models import KerasModel, ValidationCallback - vc = ValidationCallback(…) # optional - model = KerasModel(…, wandb_logger=logger) - model.fit(…, callbacks=[vc]) - logger.finish() - ``` +vc = ValidationCallback(…) # optional +model = KerasModel(…, wandb_logger=logger) +model.fit(…, callbacks=[vc]) +logger.finish() +``` - {{% /tab %}} +{{% /tab %}} - {{< /tabpane >}} +{{< /tabpane >}} diff --git a/content/guides/integrations/fastai/_index.md b/content/guides/integrations/fastai/_index.md index 87c0b5c5f..07d6f70c6 100644 --- a/content/guides/integrations/fastai/_index.md +++ b/content/guides/integrations/fastai/_index.md @@ -10,45 +10,82 @@ weight: 100 --- If you're using **fastai** to train your models, W&B has an easy integration using the `WandbCallback`. Explore the details in[ interactive docs with examples →](https://app.wandb.ai/borisd13/demo_config/reports/Visualize-track-compare-Fastai-models--Vmlldzo4MzAyNA) -## Log with W&B +## Sign up and create an API key -1. [Sign up](https://wandb.ai/site) for a free account at [https://wandb.ai/site](https://wandb.ai/site) and then log in to your wandb account. +An API key authenticates your machine to W&B. You can generate an API key from your user profile. -2. Install the wandb library on your machine in a Python 3 environment using `pip` +{{% alert %}} +For a more streamlined approach, you can generate an API key by going directly to [https://wandb.ai/authorize](https://wandb.ai/authorize). Copy the displayed API key and save it in a secure location such as a password manager. +{{% /alert %}} + +1. Click your user profile icon in the upper right corner. +1. Select **User Settings**, then scroll to the **API Keys** section. +1. Click **Reveal**. Copy the displayed API key. To hide the API key, reload the page. + +## Install the `wandb` library and log in + +To install the `wandb` library locally and log in: + +{{< tabpane text=true >}} +{{% tab header="Command Line" value="cli" %}} + +1. Set the `WANDB_API_KEY` [environment variable]({{< relref "/guides/models/track/environment-variables.md" >}}) to your API key. + + ```bash + export WANDB_API_KEY= + ``` + +1. Install the `wandb` library and log in. + + + + ```shell + pip install wandb + + wandb login + ``` + +{{% /tab %}} -3. log in to the wandb library on your machine. +{{% tab header="Python" value="python" %}} - 1. Find your API key [https://wandb.ai/authorize](https://wandb.ai/authorize). +```bash +pip install wandb +``` +```python +import wandb +wandb.login() +``` - - Command line: - ```shell - pip install wandb - wandb login - ``` - - Notebook: - ```notebook - !pip install wandb +{{% /tab %}} - import wandb - wandb.login() - ``` +{{% tab header="Python notebook" value="python-notebook" %}} +```notebook +!pip install wandb - 2. Add the `WandbCallback` to the `learner` or `fit` method: +import wandb +wandb.login() +``` - ```python - import wandb - from fastai.callback.wandb import * +{{% /tab %}} +{{< /tabpane >}} - # start logging a wandb run - wandb.init(project="my_project") +## Add the `WandbCallback` to the `learner` or `fit` method - # To log only during one training phase - learn.fit(..., cbs=WandbCallback()) +```python +import wandb +from fastai.callback.wandb import * - # To log continuously for all training phases - learn = learner(..., cbs=WandbCallback()) - ``` +# start logging a wandb run +wandb.init(project="my_project") + +# To log only during one training phase +learn.fit(..., cbs=WandbCallback()) + +# To log continuously for all training phases +learn = learner(..., cbs=WandbCallback()) +``` {{% alert %}} If you use version 1 of Fastai, refer to the [Fastai v1 docs]({{< relref "v1.md" >}}). @@ -123,7 +160,7 @@ $ torchrun --nproc_per_node 2 train.py in this case, the machine has 2 GPUs. {{% /tab %}} -{{% tab header="Notebook" value="notebook" %}} +{{% tab header="Python notebook" value="notebook" %}} You can now run distributed training directly inside a notebook. @@ -200,7 +237,7 @@ $ torchrun --nproc_per_node 2 train.py ``` {{% /tab %}} -{{% tab header="Notebook" value="notebook" %}} +{{% tab header="Python notebook" value="notebook" %}} ```python import wandb diff --git a/content/guides/integrations/huggingface.md b/content/guides/integrations/huggingface.md index be7db5c0d..5c1e60b91 100644 --- a/content/guides/integrations/huggingface.md +++ b/content/guides/integrations/huggingface.md @@ -29,30 +29,57 @@ If you'd rather dive straight into working code, check out this [Google Colab](h ## Get started: track experiments -### 1. Sign Up, install the `wandb` library and log in +### Sign up and create an API key -1. [**Sign up**](https://wandb.ai/site) for a free account +An API key authenticates your machine to W&B. You can generate an API key from your user profile. -2. Pip install the `wandb` library +{{% alert %}} +For a more streamlined approach, you can generate an API key by going directly to [https://wandb.ai/authorize](https://wandb.ai/authorize). Copy the displayed API key and save it in a secure location such as a password manager. +{{% /alert %}} -3. To log in with your training script, you'll need to sign in to you account at www.wandb.ai, then **you will find your API key on the** [**Authorize page**](https://wandb.ai/authorize)**.** +1. Click your user profile icon in the upper right corner. +1. Select **User Settings**, then scroll to the **API Keys** section. +1. Click **Reveal**. Copy the displayed API key. To hide the API key, reload the page. -If you are using Weights and Biases for the first time you might want to check out our [**quickstart**]({{< relref "/guides/quickstart.md" >}}) +### Install the `wandb` library and log in -{{< tabpane text=true >}} +To install the `wandb` library locally and log in: +{{< tabpane text=true >}} {{% tab header="Command Line" value="cli" %}} -```shell -pip install wandb +1. Set the `WANDB_API_KEY` [environment variable]({{< relref "/guides/models/track/environment-variables.md" >}}) to your API key. -wandb login -``` + ```bash + export WANDB_API_KEY= + ``` + +1. Install the `wandb` library and log in. + + + + ```shell + pip install wandb + + wandb login + ``` {{% /tab %}} {{% tab header="Python" value="python" %}} +```bash +pip install wandb +``` +```python +import wandb +wandb.login() +``` + +{{% /tab %}} + +{{% tab header="Python notebook" value="python" %}} + ```notebook !pip install wandb @@ -61,10 +88,12 @@ wandb.login() ``` {{% /tab %}} - {{< /tabpane >}} -### 2. Name the project +If you are using W&B for the first time you might want to check out our [**quickstart**]({{< relref "/guides/quickstart.md" >}}) + + +### Name the project A W&B Project is where all of the charts, data, and models logged from related runs are stored. Naming your project helps you organize your work and keep all the information about a single project in one place. @@ -78,21 +107,24 @@ WANDB_PROJECT=amazon_sentiment_analysis ``` {{% /tab %}} -{{% tab header="Notebook" value="notebook" %}} -```notebook -%env WANDB_PROJECT=amazon_sentiment_analysis +{{% tab header="Python" value="python" %}} + +```python +import os +os.environ["WANDB_PROJECT"]="amazon_sentiment_analysis" ``` {{% /tab %}} -{{% tab header="Python" value="python" %}} + +{{% tab header="Python notebook" value="notebook" %}} ```notebook -import os -os.environ["WANDB_PROJECT"]="amazon_sentiment_analysis" +%env WANDB_PROJECT=amazon_sentiment_analysis ``` {{% /tab %}} + {{< /tabpane >}} {{% alert %}} @@ -101,13 +133,13 @@ Make sure you set the project name _before_ you initialize the `Trainer`. If a project name is not specified the project name defaults to `huggingface`. -### 3. Log your training runs to W&B +### Log your training runs to W&B -This is **the most important step** when defining your `Trainer` training arguments, either inside your code or from the command line, is to set `report_to` to `"wandb"` in order enable logging with Weights & Biases. +This is **the most important step** when defining your `Trainer` training arguments, either inside your code or from the command line, is to set `report_to` to `"wandb"` in order enable logging with W&B. The `logging_steps` argument in `TrainingArguments` will control how often training metrics are pushed to W&B during training. You can also give a name to the training run in W&B using the `run_name` argument. -That's it. Now your models will log losses, evaluation metrics, model topology, and gradients to Weights & Biases while they train. +That's it. Now your models will log losses, evaluation metrics, model topology, and gradients to W&B while they train. {{< tabpane text=true >}} {{% tab header="Command Line" value="cli" %}} @@ -148,10 +180,10 @@ trainer.train() # start training and logging to W&B Using TensorFlow? Just swap the PyTorch `Trainer` for the TensorFlow `TFTrainer`. {{% /alert %}} -### 4. Turn on model checkpointing +### Turn on model checkpointing -Using Weights & Biases' [Artifacts]({{< relref "/guides/core/artifacts/" >}}), you can store up to 100GB of models and datasets for free and then use the Weights & Biases [Model Registry]({{< relref "/guides/models/registry/model_registry/" >}}) to register models to prepare them for staging or deployment in your production environment. +Using W&B's [Artifacts]({{< relref "/guides/core/artifacts/" >}}), you can store up to 100GB of models and datasets for free and then use the W&B [Model Registry]({{< relref "/guides/models/registry/model_registry/" >}}) to register models to prepare them for staging or deployment in your production environment. Logging your Hugging Face model checkpoints to Artifacts can be done by setting the `WANDB_LOG_MODEL` environment variable to one of `end` or `checkpoint` or `false`: @@ -163,25 +195,25 @@ Use `WANDB_LOG_MODEL` along with `load_best_model_at_end` to upload the best mod {{< tabpane text=true >}} -{{% tab header="Python" value="python" %}} - -```python -import os +{{% tab header="Command Line" value="cli" %}} -os.environ["WANDB_LOG_MODEL"] = "checkpoint" +```bash +WANDB_LOG_MODEL="checkpoint" ``` {{% /tab %}} -{{% tab header="Command Line" value="cli" %}} +{{% tab header="Python" value="python" %}} -```bash -WANDB_LOG_MODEL="checkpoint" +```python +import os + +os.environ["WANDB_LOG_MODEL"] = "checkpoint" ``` {{% /tab %}} -{{% tab header="Notebook" value="notebook" %}} +{{% tab header="Python notebook" value="notebook" %}} ```notebook %env WANDB_LOG_MODEL="checkpoint" @@ -200,11 +232,11 @@ However, If you pass a [`run_name`](https://huggingface.co/docs/transformers/mai {{% /alert %}} #### W&B Model Registry -Once you have logged your checkpoints to Artifacts, you can then register your best model checkpoints and centralize them across your team using the Weights & Biases **[Model Registry]({{< relref "/guides/models/registry/model_registry/" >}})**. Here you can organize your best models by task, manage model lifecycle, facilitate easy tracking and auditing throughout the ML lifecyle, and [automate]({{< relref "/guides/models/automations/project-scoped-automations/#create-a-webhook-automation" >}}) downstream actions with webhooks or jobs. +Once you have logged your checkpoints to Artifacts, you can then register your best model checkpoints and centralize them across your team using the **[Model Registry]({{< relref "/guides/models/registry/model_registry/" >}})**. Here you can organize your best models by task, manage model lifecycle, facilitate easy tracking and auditing throughout the ML lifecyle, and [automate]({{< relref "/guides/models/automations/project-scoped-automations/#create-a-webhook-automation" >}}) downstream actions with webhooks or jobs. See the [Model Registry]({{< relref "/guides/models/registry/model_registry/" >}}) documentation for how to link a model Artifact to the Model Registry. -### 5. Visualise evaluation outputs during training +### Visualise evaluation outputs during training Visualing your model outputs during training or evaluation is often essential to really understand how your model is training. @@ -215,7 +247,7 @@ See the **[Custom logging section]({{< relref "#custom-logging-log-and-view-eval {{< img src="/images/integrations/huggingface_eval_tables.png" alt="Shows a W&B Table with evaluation outputs" >}} -### 6. Finish your W&B Run (Notebook only) +### Finish your W&B Run (Notebook only) If your training is encapsulated in a Python script, the W&B run will end when your script finishes. @@ -229,7 +261,7 @@ trainer.train() # start training and logging to W&B wandb.finish() ``` -### 7. Visualize your results +### Visualize your results Once you have logged your training results you can explore your results dynamically in the [W&B Dashboard]({{< relref "/guides/models/track/workspaces.md" >}}). It's easy to compare across dozens of runs at once, zoom in on interesting findings, and coax insights out of complex data with flexible, interactive visualizations. @@ -297,7 +329,7 @@ with wandb.init( ### How do I log and view evaluation samples during training -Logging to Weights & Biases via the Transformers `Trainer` is taken care of by the [`WandbCallback`](https://huggingface.co/transformers/main_classes/callback.html#transformers.integrations.WandbCallback) in the Transformers library. If you need to customize your Hugging Face logging you can modify this callback by subclassing `WandbCallback` and adding additional functionality that leverages additional methods from the Trainer class. +Logging to W&B via the Transformers `Trainer` is taken care of by the [`WandbCallback`](https://huggingface.co/transformers/main_classes/callback.html#transformers.integrations.WandbCallback) in the Transformers library. If you need to customize your Hugging Face logging you can modify this callback by subclassing `WandbCallback` and adding additional functionality that leverages additional methods from the Trainer class. Below is the general pattern to add this new callback to the HF Trainer, and further down is a code-complete example to log evaluation outputs to a W&B Table: @@ -510,7 +542,7 @@ Read the full report [here](https://wandb.ai/cayush/bert-finetuning/reports/Sent A Step by Step Guide to Tracking Hugging Face Model Performance -* We use Weights & Biases and Hugging Face transformers to train DistilBERT, a Transformer that's 40% smaller than BERT but retains 97% of BERT's accuracy, on the GLUE benchmark +* We use W&B and Hugging Face transformers to train DistilBERT, a Transformer that's 40% smaller than BERT but retains 97% of BERT's accuracy, on the GLUE benchmark * The GLUE benchmark is a collection of nine datasets and tasks for training NLP models Read the full report [here](https://wandb.ai/jxmorris12/huggingface-demo/reports/A-Step-by-Step-Guide-to-Tracking-HuggingFace-Model-Performance--VmlldzoxMDE2MTU). diff --git a/content/guides/integrations/kubeflow-pipelines-kfp.md b/content/guides/integrations/kubeflow-pipelines-kfp.md index 7b3932bf1..d5a2563d0 100644 --- a/content/guides/integrations/kubeflow-pipelines-kfp.md +++ b/content/guides/integrations/kubeflow-pipelines-kfp.md @@ -7,7 +7,7 @@ menu: title: Kubeflow Pipelines (kfp) weight: 170 --- -## Overview + [Kubeflow Pipelines (kfp) ](https://www.kubeflow.org/docs/components/pipelines/overview/)is a platform for building and deploying portable, scalable machine learning (ML) workflows based on Docker containers. @@ -15,36 +15,69 @@ This integration lets users apply decorators to kfp python functional components This feature was enabled in `wandb==0.12.11` and requires `kfp<2.0.0` -## Quickstart +## Sign up and create an API key + +An API key authenticates your machine to W&B. You can generate an API key from your user profile. + +{{% alert %}} +For a more streamlined approach, you can generate an API key by going directly to [https://wandb.ai/authorize](https://wandb.ai/authorize). Copy the displayed API key and save it in a secure location such as a password manager. +{{% /alert %}} -### Install W&B and login +1. Click your user profile icon in the upper right corner. +1. Select **User Settings**, then scroll to the **API Keys** section. +1. Click **Reveal**. Copy the displayed API key. To hide the API key, reload the page. + +## Install the `wandb` library and log in + +To install the `wandb` library locally and log in: {{< tabpane text=true >}} +{{% tab header="Command Line" value="cli" %}} -{{% tab header="Notebook" value="notebook" %}} +1. Set the `WANDB_API_KEY` [environment variable]({{< relref "/guides/models/track/environment-variables.md" >}}) to your API key. -```bash -!pip install kfp wandb + ```bash + export WANDB_API_KEY= + ``` + +1. Install the `wandb` library and log in. + + + + ```shell + pip install wandb + + wandb login + ``` +{{% /tab %}} + +{{% tab header="Python" value="python" %}} + +```bash +pip install wandb +``` +```python import wandb wandb.login() ``` {{% /tab %}} -{{% tab header="Command Line" value="cli" %}} +{{% tab header="Python notebook" value="notebook" %}} -```python -pip install kfp wandb -wandb login +```notebook +!pip install wandb + +import wandb +wandb.login() ``` {{% /tab %}} - {{< /tabpane >}} -### Decorate your components +## Decorate your components Add the `@wandb_log` decorator and create your components as usual. This will automatically log the input/outputs parameters and artifacts to W&B each time you run your pipeline. @@ -61,7 +94,7 @@ def add(a: float, b: float) -> float: add = components.create_component_from_func(add) ``` -### Pass environment variables to containers +## Pass environment variables to containers You may need to explicitly pass [environment variables]({{< relref "/guides/models/track/environment-variables.md" >}}) to your containers. For two-way linking, you should also set the environment variables `WANDB_KUBEFLOW_URL` to the base URL of your Kubeflow Pipelines instance. For example, `https://kubeflow.mysite.com`. diff --git a/content/guides/integrations/lightning.md b/content/guides/integrations/lightning.md index ea82f9048..1c83651e8 100644 --- a/content/guides/integrations/lightning.md +++ b/content/guides/integrations/lightning.md @@ -53,29 +53,56 @@ fabric.log_dict({"important_metric": important_metric}) {{< img src="/images/integrations/n6P7K4M.gif" alt="Interactive dashboards accessible anywhere, and more!" >}} -## Sign up and Log in to wandb +### Sign up and create an API key -1. [**Sign up**](https://wandb.ai/site) for a free account. +An API key authenticates your machine to W&B. You can generate an API key from your user profile. -2. Run example commands to: - 1. Use `pip` to install the `wandb` library. - 2. Signs in to you account at www.wandb.ai in your browser. +{{% alert %}} +For a more streamlined approach, you can generate an API key by going directly to [https://wandb.ai/authorize](https://wandb.ai/authorize). Copy the displayed API key and save it in a secure location such as a password manager. +{{% /alert %}} + +1. Click your user profile icon in the upper right corner. +1. Select **User Settings**, then scroll to the **API Keys** section. +1. Click **Reveal**. Copy the displayed API key. To hide the API key, reload the page. -3. In your browser, find your API key on the [Authorize page](https://wandb.ai/authorize). +### Install the `wandb` library and log in -4. If you are using Weights and Biases for the first time you might want to check out our [**quickstart**]({{< relref "/guides/quickstart.md" >}}) +To install the `wandb` library locally and log in: {{< tabpane text=true >}} {{% tab header="Command Line" value="cli" %}} +1. Set the `WANDB_API_KEY` [environment variable]({{< relref "/guides/models/track/environment-variables.md" >}}) to your API key. + + ```bash + export WANDB_API_KEY= + ``` + +1. Install the `wandb` library and log in. + + + + ```shell + pip install wandb + + wandb login + ``` + +{{% /tab %}} + +{{% tab header="Python" value="python" %}} + ```bash pip install wandb - -wandb login +``` +```python +import wandb +wandb.login() ``` {{% /tab %}} -{{% tab header="Notebook" value="notebook" %}} + +{{% tab header="Python notebook" value="notebook" %}} ```notebook !pip install wandb diff --git a/content/guides/integrations/metaflow.md b/content/guides/integrations/metaflow.md index 9df53a69d..0560fcc31 100644 --- a/content/guides/integrations/metaflow.md +++ b/content/guides/integrations/metaflow.md @@ -18,30 +18,65 @@ This integration lets users apply decorators to Metaflow [steps and flows](https ## Quickstart -### Install W&B and login +### Sign up and create an API key + +An API key authenticates your machine to W&B. You can generate an API key from your user profile. + +{{% alert %}} +For a more streamlined approach, you can generate an API key by going directly to [https://wandb.ai/authorize](https://wandb.ai/authorize). Copy the displayed API key and save it in a secure location such as a password manager. +{{% /alert %}} + +1. Click your user profile icon in the upper right corner. +1. Select **User Settings**, then scroll to the **API Keys** section. +1. Click **Reveal**. Copy the displayed API key. To hide the API key, reload the page. + +### Install the `wandb` library and log in + +To install the `wandb` library locally and log in: {{< tabpane text=true >}} +{{% tab header="Command Line" value="cli" %}} -{{% tab header="Notebook" value="notebook" %}} +1. Set the `WANDB_API_KEY` [environment variable]({{< relref "/guides/models/track/environment-variables.md" >}}) to your API key. -```python -!pip install -Uqqq metaflow fastcore wandb + ```bash + export WANDB_API_KEY= + ``` -import wandb -wandb.login() -``` +1. Install the `wandb` library and log in. + + + + ```shell + pip install -Uqqq metaflow fastcore wandb + + wandb login + ``` {{% /tab %}} -{{% tab header="Command Line" value="cli" %}} +{{% tab header="Python" value="python" %}} ```bash pip install -Uqqq metaflow fastcore wandb -wandb login +``` +```python +import wandb +wandb.login() ``` {{% /tab %}} +{{% tab header="Python notebook" value="notebook" %}} + +```notebook +!pip install -Uqqq metaflow fastcore wandb + +import wandb +wandb.login() +``` + +{{% /tab %}} {{< /tabpane >}} ### Decorate your flows and steps @@ -127,7 +162,7 @@ class WandbExampleFlow(FlowSpec): You can access the information we've captured in three ways: inside the original Python process being logged using the [`wandb` client library]({{< relref "/ref/python/" >}}), with the [web app UI]({{< relref "/guides/models/track/workspaces.md" >}}), or programmatically using [our Public API]({{< relref "/ref/python/public-api/" >}}). `Parameter`s are saved to W&B's [`config`]({{< relref "/guides/models/track/config.md" >}}) and can be found in the [Overview tab]({{< relref "/guides/models/track/runs/#overview-tab" >}}). `datasets`, `models`, and `others` are saved to [W&B Artifacts]({{< relref "/guides/core/artifacts/" >}}) and can be found in the [Artifacts tab]({{< relref "/guides/models/track/runs/#artifacts-tab" >}}). Base python types are saved to W&B's [`summary`]({{< relref "/guides/models/track/log/" >}}) dict and can be found in the Overview tab. See our [guide to the Public API]({{< relref "/guides/models/track/public-api-guide.md" >}}) for details on using the API to get this information programmatically from outside . -### Cheat sheet +### Quick reference | Data | Client library | UI | | ----------------------------------------------- | ----------------------------------------- | --------------------- | diff --git a/content/guides/integrations/paddledetection.md b/content/guides/integrations/paddledetection.md index 5bb54a3de..c81e3e848 100644 --- a/content/guides/integrations/paddledetection.md +++ b/content/guides/integrations/paddledetection.md @@ -18,40 +18,71 @@ The PaddleDetection `WandbLogger` logs your training and evaluation metrics to W [**Read a W&B blog post**](https://wandb.ai/manan-goel/PaddleDetectionYOLOX/reports/Object-Detection-with-PaddleDetection-and-W-B--VmlldzoyMDU4MjY0) which illustrates how to integrate a YOLOX model with PaddleDetection on a subset of the `COCO2017` dataset. -## Use PaddleDetection with W&B +## Sign up and create an API key -### Sign up and log in to W&B +An API key authenticates your machine to W&B. You can generate an API key from your user profile. -[**Sign up**](https://wandb.ai/site) for a free Weights & Biases account, then pip install the wandb library. To login, you'll need to be signed in to you account at www.wandb.ai. Once signed in **you will find your API key on the** [**Authorize page**](https://wandb.ai/authorize)**.** +{{% alert %}} +For a more streamlined approach, you can generate an API key by going directly to [https://wandb.ai/authorize](https://wandb.ai/authorize). Copy the displayed API key and save it in a secure location such as a password manager. +{{% /alert %}} -{{< tabpane text=true >}} +1. Click your user profile icon in the upper right corner. +1. Select **User Settings**, then scroll to the **API Keys** section. +1. Click **Reveal**. Copy the displayed API key. To hide the API key, reload the page. + +## Install the `wandb` library and log in +To install the `wandb` library locally and log in: + +{{< tabpane text=true >}} {{% tab header="Command Line" value="cli" %}} -```shell -pip install wandb +1. Set the `WANDB_API_KEY` [environment variable]({{< relref "/guides/models/track/environment-variables.md" >}}) to your API key. + + ```bash + export WANDB_API_KEY= + ``` + +1. Install the `wandb` library and log in. + + + + ```shell + pip install wandb + + wandb login + ``` + +{{% /tab %}} -wandb login +{{% tab header="Python" value="python" %}} + +```bash +pip install wandb +``` +```python +import wandb +wandb.login() ``` {{% /tab %}} -{{% tab header="Notebook" value="notebook" %}} +{{% tab header="Python notebook" value="python" %}} ```notebook !pip install wandb +import wandb wandb.login() ``` {{% /tab %}} - {{< /tabpane >}} -### Activate the `WandbLogger` in your training script - -#### Use the CLI +## Activate the `WandbLogger` in your training script +{{< tabpane text=true >}} +{{% tab header="Command Line" value="cli" %}} To use wandb via arguments to `train.py` in [PaddleDetection](https://github.com/PaddlePaddle/PaddleDetection/): * Add the `--use_wandb` flag @@ -67,10 +98,9 @@ python tools/train.py wandb-entity=MyTeam \ wandb-save_dir=./logs ``` - -#### Use a `config.yml` file - -You can also activate wandb via the config file. Add the wandb arguments to the config.yml file under the wandb header like so: +{{% /tab %}} +{{% tab header="`config.yml`" value="config" %}} +Add the wandb arguments to the config.yml file under the `wandb` key: ``` wandb: @@ -79,9 +109,11 @@ wandb: save_dir: ./logs ``` -Once you run your `train.py` file with Weights & Biases turned on, a link will be generated to bring you to your W&B dashboard: +When you run your `train.py` file, it generates a link to your W&B dashboard. {{< img src="/images/integrations/paddledetection_wb_dashboard.png" alt="A Weights & Biases Dashboard" >}} +{{% /tab %}} +{{< /tabpane >}} ## Feedback or issues diff --git a/content/guides/integrations/paddleocr.md b/content/guides/integrations/paddleocr.md index 30ab46945..bd89362d1 100644 --- a/content/guides/integrations/paddleocr.md +++ b/content/guides/integrations/paddleocr.md @@ -13,31 +13,68 @@ weight: 280 [**Read here**](https://wandb.ai/manan-goel/text_detection/reports/Train-and-Debug-Your-OCR-Models-with-PaddleOCR-and-W-B--VmlldzoyMDUwMDIw) to see how to train a model with PaddleOCR on the ICDAR2015 dataset. This also comes with a [**Google Colab**](https://colab.research.google.com/drive/1id2VTIQ5-M1TElAkzjzobUCdGeJeW-nV?usp=sharing) and the corresponding live W&B dashboard is available [**here**](https://wandb.ai/manan-goel/text_detection). There is also a Chinese version of this blog here: [**W&B对您的OCR模型进行训练和调试**](https://wandb.ai/wandb_fc/chinese/reports/W-B-OCR---VmlldzoyMDk1NzE4) -## Use PaddleOCR with Weights & Biases +## Sign up and create an API key -### 1. Sign up and Log in to wandb +An API key authenticates your machine to W&B. You can generate an API key from your user profile. -[**Sign up**](https://wandb.ai/site) for a free account, then from the command line install the wandb library in a Python 3 environment. To login, you'll need to be signed in to you account at www.wandb.ai, then **you will find your API key on the** [**Authorize page**](https://wandb.ai/authorize). +{{% alert %}} +For a more streamlined approach, you can generate an API key by going directly to [https://wandb.ai/authorize](https://wandb.ai/authorize). Copy the displayed API key and save it in a secure location such as a password manager. +{{% /alert %}} + +1. Click your user profile icon in the upper right corner. +1. Select **User Settings**, then scroll to the **API Keys** section. +1. Click **Reveal**. Copy the displayed API key. To hide the API key, reload the page. + +## Install the `wandb` library and log in + +To install the `wandb` library locally and log in: {{< tabpane text=true >}} {{% tab header="Command Line" value="cli" %}} + +1. Set the `WANDB_API_KEY` [environment variable]({{< relref "/guides/models/track/environment-variables.md" >}}) to your API key. + + ```bash + export WANDB_API_KEY= + ``` + +1. Install the `wandb` library and log in. + + + + ```shell + pip install wandb + + wandb login + ``` + +{{% /tab %}} + +{{% tab header="Python" value="python" %}} + ```bash pip install wandb - -wandb login ``` +```python +import wandb +wandb.login() +``` + {{% /tab %}} -{{% tab header="Notebook" value="notebook" %}} -```python +{{% tab header="Python notebook" value="notebook" %}} + +```notebook !pip install wandb +import wandb wandb.login() ``` + {{% /tab %}} {{< /tabpane >}} -### 2. Add wandb to your `config.yml` file +## Add wandb to your `config.yml` file PaddleOCR requires configuration variables to be provided using a yaml file. Adding the following snippet at the end of the configuration yaml file will automatically log all training and validation metrics to a W&B dashboard along with model checkpoints: @@ -55,7 +92,7 @@ wandb: name: MyOCRModel # (optional) this is the name of the wandb run ``` -### 3. Pass the `config.yml` file to `train.py` +## Pass the `config.yml` file to `train.py` The yaml file is then provided as an argument to the [training script](https://github.com/PaddlePaddle/PaddleOCR/blob/release/2.5/tools/train.py) available in the PaddleOCR repository. @@ -71,6 +108,6 @@ Once you run your `train.py` file with Weights & Biases turned on, a link will b {{< img src="/images/integrations/paddleocr_wb_dashboard3.png" alt="W&B Dashboard for the Text Detection Model" >}} -## Feedback or Issues? +## Feedback or issues If you have any feedback or issues about the Weights & Biases integration please open an issue on the [PaddleOCR GitHub](https://github.com/PaddlePaddle/PaddleOCR) or email support@wandb.com. \ No newline at end of file diff --git a/content/guides/integrations/pytorch-geometric.md b/content/guides/integrations/pytorch-geometric.md index a720baa97..286864419 100644 --- a/content/guides/integrations/pytorch-geometric.md +++ b/content/guides/integrations/pytorch-geometric.md @@ -6,26 +6,62 @@ menu: title: PyTorch Geometric weight: 310 --- -[PyTorch Geometric](https://github.com/pyg-team/pytorch_geometric) or PyG is one of the most popular libraries for geometric deep learning and W&B works extremely well with it for visualizing graphs and tracking experiments. +[PyTorch Geometric](https://github.com/pyg-team/pytorch_geometric) or PyG is one of the most popular libraries for geometric deep learning and W&B works extremely well with it for visualizing graphs and tracking experiments. -## Get started +After you have installed Pytorch Geometric, follow these steps to get started. -After you have installed pytorch geometric, install the wandb library and login +## Sign up and create an API key + +An API key authenticates your machine to W&B. You can generate an API key from your user profile. + +{{% alert %}} +For a more streamlined approach, you can generate an API key by going directly to [https://wandb.ai/authorize](https://wandb.ai/authorize). Copy the displayed API key and save it in a secure location such as a password manager. +{{% /alert %}} + +1. Click your user profile icon in the upper right corner. +1. Select **User Settings**, then scroll to the **API Keys** section. +1. Click **Reveal**. Copy the displayed API key. To hide the API key, reload the page. + +## Install the `wandb` library and log in + +To install the `wandb` library locally and log in: {{< tabpane text=true >}} +{{% tab header="Command Line" value="cli" %}} + +1. Set the `WANDB_API_KEY` [environment variable]({{< relref "/guides/models/track/environment-variables.md" >}}) to your API key. + + ```bash + export WANDB_API_KEY= + ``` + +1. Install the `wandb` library and log in. + + -{{% tab header="Command Line" value="script" %}} + ```shell + pip install wandb + + wandb login + ``` + +{{% /tab %}} + +{{% tab header="Python" value="python" %}} ```bash pip install wandb -wandb login +``` +```python +import wandb +wandb.login() ``` {{% /tab %}} -{{% tab header="Notebook" value="notebook" %}} +{{% tab header="Python notebook" value="notebook" %}} -```python +```notebook !pip install wandb import wandb @@ -33,7 +69,6 @@ wandb.login() ``` {{% /tab %}} - {{< /tabpane >}} ## Visualize the graphs diff --git a/content/guides/integrations/scikit.md b/content/guides/integrations/scikit.md index df7e760b8..9e683c4ec 100644 --- a/content/guides/integrations/scikit.md +++ b/content/guides/integrations/scikit.md @@ -10,34 +10,61 @@ You can use wandb to visualize and compare your scikit-learn models' performance ## Get started -### Sign up and Log in to wandb +### Sign up and create an API key -To get started: +An API key authenticates your machine to W&B. You can generate an API key from your user profile. -1. [**Sign up**](https://wandb.ai/site) for a free account. +{{% alert %}} +For a more streamlined approach, you can generate an API key by going directly to [https://wandb.ai/authorize](https://wandb.ai/authorize). Copy the displayed API key and save it in a secure location such as a password manager. +{{% /alert %}} -2. Use this code to install the `wandb` library and sign in to your wandb account. +1. Click your user profile icon in the upper right corner. +1. Select **User Settings**, then scroll to the **API Keys** section. +1. Click **Reveal**. Copy the displayed API key. To hide the API key, reload the page. -3. Find your API key on the [Authorize page](https://wandb.ai/authorize). +### Install the `wandb` library and log in -4. If you are using Weights and Biases for the first time,check out a [quickstart]({{< relref "/guides/quickstart.md" >}}) +To install the `wandb` library locally and log in: {{< tabpane text=true >}} {{% tab header="Command Line" value="cli" %}} +1. Set the `WANDB_API_KEY` [environment variable]({{< relref "/guides/models/track/environment-variables.md" >}}) to your API key. + + ```bash + export WANDB_API_KEY= + ``` + +1. Install the `wandb` library and log in. + + + + ```shell + pip install wandb + + wandb login + ``` + +{{% /tab %}} + +{{% tab header="Python" value="python" %}} + ```bash pip install wandb - -wandb login +``` +```python +import wandb +wandb.login() ``` {{% /tab %}} -{{% tab header="Notebook" value="notebook" %}} +{{% tab header="Python notebook" value="notebook" %}} -```python +```notebook !pip install wandb +import wandb wandb.login() ``` diff --git a/content/guides/integrations/spacy.md b/content/guides/integrations/spacy.md index 9924014a1..9d6d28a98 100644 --- a/content/guides/integrations/spacy.md +++ b/content/guides/integrations/spacy.md @@ -8,20 +8,58 @@ weight: 410 --- [spaCy](https://spacy.io) is a popular "industrial-strength" NLP library: fast, accurate models with a minimum of fuss. As of spaCy v3, Weights and Biases can now be used with [`spacy train`](https://spacy.io/api/cli#train) to track your spaCy model's training metrics as well as to save and version your models and datasets. And all it takes is a few added lines in your configuration. -## 1. Install the `wandb` library and log in +## Sign up and create an API key + +An API key authenticates your machine to W&B. You can generate an API key from your user profile. + +{{% alert %}} +For a more streamlined approach, you can generate an API key by going directly to [https://wandb.ai/authorize](https://wandb.ai/authorize). Copy the displayed API key and save it in a secure location such as a password manager. +{{% /alert %}} + +1. Click your user profile icon in the upper right corner. +1. Select **User Settings**, then scroll to the **API Keys** section. +1. Click **Reveal**. Copy the displayed API key. To hide the API key, reload the page. + +## Install the `wandb` library and log in + +To install the `wandb` library locally and log in: {{< tabpane text=true >}} {{% tab header="Command Line" value="cli" %}} -```python +1. Set the `WANDB_API_KEY` [environment variable]({{< relref "/guides/models/track/environment-variables.md" >}}) to your API key. + + ```bash + export WANDB_API_KEY= + ``` + +1. Install the `wandb` library and log in. + + + + ```shell + pip install wandb + + wandb login + ``` + +{{% /tab %}} + +{{% tab header="Python" value="python" %}} + +```bash pip install wandb -wandb login +``` +```python +import wandb +wandb.login() ``` {{% /tab %}} -{{% tab header="Notebook" value="notebook" %}} -```python +{{% tab header="Python notebook" value="notebook" %}} + +```notebook !pip install wandb import wandb @@ -31,7 +69,7 @@ wandb.login() {{% /tab %}} {{< /tabpane >}} -## 2. Add the `WandbLogger` to your spaCy config file +## Add the `WandbLogger` to your spaCy config file spaCy config files are used to specify all aspects of training, not just logging -- GPU allocation, optimizer choice, dataset paths, and more. Minimally, under `[training.logger]` you need to provide the key `@loggers` with the value `"spacy.WandbLogger.v3"`, plus a `project_name`. @@ -57,7 +95,7 @@ model_log_interval = 1000 | `entity` | `Optional str` . If passed, the run will be created in the specified entity | | `run_name` | `Optional str` . If specified, the run will be created with the specified name. | -## 3. Start training +## Start training Once you have added the `WandbLogger` to your spaCy training config you can run `spacy train` as usual. @@ -75,10 +113,10 @@ python -m spacy train \ {{% /tab %}} -{{% tab header="Notebook" value="notebook" %}} +{{% tab header="Python" value="python" %}} ```python -!python -m spacy train \ +python -m spacy train \ config.cfg \ --output ./output \ --paths.train ./train \ @@ -87,6 +125,17 @@ python -m spacy train \ {{% /tab %}} +{{% tab header="Python notebook" value="notebook" %}} + +```notebook +!python -m spacy train \ + config.cfg \ + --output ./output \ + --paths.train ./train \ + --paths.dev ./dev +``` + +{{% /tab %}} {{< /tabpane >}} When training begins, a link to your training run's [W&B page]({{< relref "/guides/models/track/runs/" >}}) will be output which will take you to this run's experiment tracking [dashboard]({{< relref "/guides/models/track/workspaces.md" >}}) in the Weights & Biases web UI. \ No newline at end of file diff --git a/content/guides/integrations/yolox.md b/content/guides/integrations/yolox.md index 9e8347a92..456454f82 100644 --- a/content/guides/integrations/yolox.md +++ b/content/guides/integrations/yolox.md @@ -8,15 +8,74 @@ title: YOLOX weight: 490 --- -[YOLOX](https://github.com/Megvii-BaseDetection/YOLOX) is an anchor-free version of YOLO with strong performance for object detection. You can use the YOLOX Weights & Biases integration to turn on logging of metrics related to training, validation, and the system, and you can interactively validate predictions with a single command-line argument. +[YOLOX](https://github.com/Megvii-BaseDetection/YOLOX) is an anchor-free version of YOLO with strong performance for object detection. You can use the YOLOX W&B integration to turn on logging of metrics related to training, validation, and the system, and you can interactively validate predictions with a single command-line argument. -## Get started +## Sign up and create an API key -To use YOLOX with Weights & Biases you will first need to sign up for a Weights & Biases account [here](https://wandb.ai/site). +An API key authenticates your machine to W&B. You can generate an API key from your user profile. -Then just use the `--logger wandb` command line argument to turn on logging with wandb. Optionally you can also pass all of the arguments that [wandb.init]({{< relref "/ref/python/init" >}}) would expect, just prepend `wandb-` to the start of each argument +{{% alert %}} +For a more streamlined approach, you can generate an API key by going directly to [https://wandb.ai/authorize](https://wandb.ai/authorize). Copy the displayed API key and save it in a secure location such as a password manager. +{{% /alert %}} -`num_eval_imges` controls the number of validation set images and predictions that are logged to Weights & Biases tables for model evaluation. +1. Click your user profile icon in the upper right corner. +1. Select **User Settings**, then scroll to the **API Keys** section. +1. Click **Reveal**. Copy the displayed API key. To hide the API key, reload the page. + +## Install the `wandb` library and log in + +To install the `wandb` library locally and log in: + +{{< tabpane text=true >}} +{{% tab header="Command Line" value="cli" %}} + +1. Set the `WANDB_API_KEY` [environment variable]({{< relref "/guides/models/track/environment-variables.md" >}}) to your API key. + + ```bash + export WANDB_API_KEY= + ``` + +1. Install the `wandb` library and log in. + + + + ```shell + pip install wandb + + wandb login + ``` + +{{% /tab %}} + +{{% tab header="Python" value="python" %}} + +```bash +pip install wandb +``` +```python +import wandb +wandb.login() +``` + +{{% /tab %}} + +{{% tab header="Python notebook" value="python" %}} + +```notebook +!pip install wandb + +import wandb +wandb.login() +``` + +{{% /tab %}} +{{< /tabpane >}} + +## Log metrics + +Use the `--logger wandb` command line argument to turn on logging with wandb. Optionally you can also pass all of the arguments that [`wandb.init`]({{< relref "/ref/python/init" >}}) expects; prepend each argument with `wandb-`. + +`num_eval_imges` controls the number of validation set images and predictions that are logged to W&B tables for model evaluation. ```shell # login to wandb @@ -39,4 +98,4 @@ python tools/train.py .... --logger wandb \ {{< img src="/images/integrations/yolox_example_dashboard.png" alt="" >}} -Any questions or issues about this Weights & Biases integration? Open an issue in the [YOLOX repository](https://github.com/Megvii-BaseDetection/YOLOX). \ No newline at end of file +Any questions or issues about this W&B integration? Open an issue in the [YOLOX repository](https://github.com/Megvii-BaseDetection/YOLOX). \ No newline at end of file diff --git a/content/guides/models/track/environment-variables.md b/content/guides/models/track/environment-variables.md index 2c7921e41..1f89e4ded 100644 --- a/content/guides/models/track/environment-variables.md +++ b/content/guides/models/track/environment-variables.md @@ -39,7 +39,7 @@ Use these optional environment variables to do things like set up authentication | Variable name | Usage | | --------------------------- | ---------- | | **WANDB_ANONYMOUS** | Set this to `allow`, `never`, or `must` to let users create anonymous runs with secret urls. | -| **WANDB_API_KEY** | Sets the authentication key associated with your account. You can find your key on [your settings page](https://app.wandb.ai/settings). This must be set if `wandb login` hasn't been run on the remote machine. | +| **WANDB_API_KEY** | Sets the authentication key associated with your account. You can find your key on [your settings page](https://app.wandb.ai/settings). This must be set if `wandb login` hasn't been run on the remote machine. | | **WANDB_BASE_URL** | If you're using [wandb/local]({{< relref "/guides/hosting/" >}}) you should set this environment variable to `http://YOUR_IP:YOUR_PORT` | | **WANDB_CACHE_DIR** | This defaults to \~/.cache/wandb, you can override this location with this environment variable | | **WANDB_CONFIG_DIR** | This defaults to \~/.config/wandb, you can override this location with this environment variable | diff --git a/content/guides/models/track/public-api-guide.md b/content/guides/models/track/public-api-guide.md index ada92b6cc..2597b259c 100644 --- a/content/guides/models/track/public-api-guide.md +++ b/content/guides/models/track/public-api-guide.md @@ -163,12 +163,18 @@ Use the Public API to export or update data that you have saved to W&B. Before u See the [Generated Reference Docs]({{< relref "/ref/python/public-api/" >}}) for details on available functions. -### Authentication +### Create an API key -Authenticate your machine with your [API key](https://wandb.ai/authorize) in one of two ways: +An API key authenticates your machine to W&B. You can generate an API key from your user profile. + +{{% alert %}} +For a more streamlined approach, you can generate an API key by going directly to [https://wandb.ai/authorize](https://wandb.ai/authorize). Copy the displayed API key and save it in a secure location such as a password manager. +{{% /alert %}} + +1. Click your user profile icon in the upper right corner. +1. Select **User Settings**, then scroll to the **API Keys** section. +1. Click **Reveal**. Copy the displayed API key. To hide the API key, reload the page. -1. Run `wandb login` on the command line and paste in your API key. -2. Set the `WANDB_API_KEY` environment variable to your API key. ### Find the run path @@ -416,7 +422,7 @@ run.summary["accuracy_histogram"] = wandb.Histogram(numpy_array) run.summary.update() ``` -### Rename a metric in a run, after the run has finished +### Rename a metric in a completed run This example renames a summary column in your tables. @@ -431,10 +437,12 @@ del run.summary["old_name"] run.summary.update() ``` -{{% alert color="secondary" %}} +{{% alert %}} Renaming a column only applies to tables. Charts will still refer to metrics by their original names. {{% /alert %}} + + ### Update config for an existing run This examples updates one of your configuration settings. diff --git a/content/guides/quickstart.md b/content/guides/quickstart.md index 044df94c6..f8c1e07bc 100644 --- a/content/guides/quickstart.md +++ b/content/guides/quickstart.md @@ -10,67 +10,69 @@ weight: 2 --- Install W&B and start tracking your machine learning experiments in minutes. -## 1. Create an account and install W&B -Before you get started, make sure you create an account and install W&B: +## Sign up and create an API key -1. [Sign up](https://wandb.ai/site) for a free account at [https://wandb.ai/site](https://wandb.ai/site) and then log in to your wandb account. -2. Install the wandb library on your machine in a Python 3 environment using [`pip`](https://pypi.org/project/wandb/). -3. Navigate to [the **Authorize** page](https://wandb.ai/authorize) to create an API key, and save it for later use. +An API key authenticates your machine to W&B. You can generate an API key from your user profile. -The following code snippets demonstrate how to install and log into W&B using the W&B CLI and Python Library: +{{% alert %}} +For a more streamlined approach, you can generate an API key by going directly to [https://wandb.ai/authorize](https://wandb.ai/authorize). Copy the displayed API key and save it in a secure location such as a password manager. +{{% /alert %}} + +1. Click your user profile icon in the upper right corner. +1. Select **User Settings**, then scroll to the **API Keys** section. +1. Click **Reveal**. Copy the displayed API key. To hide the API key, reload the page. + +## Install the `wandb` library and log in + +To install the `wandb` library locally and log in: {{< tabpane text=true >}} -{{% tab "Command-Line" %}} -Install the CLI and Python library for interacting with the Weights and Biases API: +{{% tab header="Command Line" value="cli" %}} -```bash -pip install wandb -``` -{{% /tab %}} -{{% tab "Notebook" %}} -Install the CLI and Python library for interacting with the Weights and Biases API: +1. Set the `WANDB_API_KEY` [environment variable]({{< relref "/guides/models/track/environment-variables.md" >}}) to your API key. + ```bash + export WANDB_API_KEY= + ``` -```notebook -!pip install wandb -``` -{{% /tab %}} -{{< /tabpane >}} +1. Install the `wandb` library and log in. -## 2. Log in to W&B -{{< tabpane text=true >}} -{{% tab "Command-Line" %}} -Next, log in to W&B: + ```shell + pip install wandb -```bash -wandb login -``` + wandb login + ``` + +{{% /tab %}} -Or if you are using [W&B Server]({{< relref "/guides/hosting/" >}}) (including **Dedicated Cloud** or **Self-managed**): +{{% tab header="Python" value="python" %}} ```bash -wandb login --relogin --host=http://your-shared-local-host.com +pip install wandb +``` +```python +import wandb +wandb.login() ``` -If needed, ask your deployment admin for the hostname. - -Provide [your API key](https://wandb.ai/authorize) when prompted. {{% /tab %}} -{{% tab "Notebook" %}} -Next, import the W&B Python SDK and log in: -```python +{{% tab header="Python notebook" value="notebook" %}} + +```notebook +!pip install wandb + +import wandb wandb.login() ``` -Provide [your API key](https://wandb.ai/authorize) when prompted. {{% /tab %}} {{< /tabpane >}} -## 3. Start a run and track hyperparameters +## Start a run and track hyperparameters Initialize a W&B Run object in your Python script or notebook with [`wandb.init()`]({{< relref "/ref/python/run.md" >}}) and pass a dictionary to the `config` parameter with key-value pairs of hyperparameter names and values: @@ -90,10 +92,7 @@ run = wandb.init( A [run]({{< relref "/guides/models/track/runs/" >}}) is the basic building block of W&B. You will use them often to [track metrics]({{< relref "/guides/models/track/" >}}), [create logs]({{< relref "/guides/core/artifacts/" >}}), and more. - - - -## Putting it all together +## Put it all together Putting it all together, your training script might look similar to the following code example. The highlighted code shows W&B-specific code. Note that we added code that mimics machine learning training.