Track Your Java Model's Performance With W&B

Overview of our new [BETA] Java client library. Made by Justin Brooks using Weights & Biases
Justin Brooks
Similar to our Python library, we offer a Java client to instrument your machine learning model and track experiments. This library consists of two simple classes that are used as a wrapper around the Python Library.

Quick Links

Getting Started

  1. Install the latest version of the wandb Python client: pip install wandb[grpc] --upgrade
  2. Simply include the Wandb jar file in your Java Project using maven:
    com.wandb.client client-ng-java 1.0-SNAPSHOT

Features

The motivation around creating the Java client was to allow users who build and train models in java to easily integrate with the wandb tools. Adding the wandb jar file to your project will give you access to some of the features available in the python client:
Currently, the client only supports logging of basic JSONObject, but we have plans to add support for more command datatypes!

Example

In this example, we will use the new Java Client to plot a sin function.
System.out.println("Hello from wandb in java!");// Create custom config object for fun!JSONObject config = new JSONObject();config.put("configNumber", 100);config.put("configString", "Config string value!");// Using builder to create run objectSystem.out.println("Creating wandb run object.");WandbRun run = new WandbRun.Builder() .withConfig(config) .build();// Print out url to monitor run on wandbrun.printRunInfo();// Compute and log values for a sin functionfor(double i = 0.0; i < 2*Math.PI; i += 0.1) { JSONObject log = new JSONObject(); double value = Math.sin(i); log.put("x1", value); log.put("x2", value*2); run.log(log); }// Finish the wandb run (this is required to be called at the end of your run.)run.finish();
For the full example, including the pom.xml configuration, check out this example in the examples repo.
In order to run this example, you must have Java JDK and Maven installed on your machine. You must also install the wandb[grpc] package and be authenticated by calling wandb login MY_API_KEY.
The outputs created from this example can be seen below.