Skip to main content

Record experiment data easily

Project description

record-keeper

Installation

pip install record-keeper

The Problem:

When running machine-learning experiments, having more logged data is usually better than less. But adding new series of data to log can often require changes to your training code. When you want to log dozens of different series of data, your code starts to look awful.

The Solution:

Use RecordKeeper, and easily add loggable information when you write a new class. The example below is taken from the pytorch-metric-learning library.

First, create a list that contains the names of the attributes you want to record (self.record_these in the example below).

class ContrastiveLoss(GenericPairLoss):
    def __init__(self, pos_margin=0, neg_margin=1, use_similarity=False, power=1, avg_non_zero_only=True, **kwargs):
        ...
        self.num_non_zero_pos_pairs = 0
        self.num_non_zero_neg_pairs = 0
        self.record_these = ["num_non_zero_pos_pairs", "num_non_zero_neg_pairs"]
        ...
    ...

Then tell RecordKeeper the name of the list to read. RecordKeeper will log and save all the attributes described in the list.

from torch.utils.tensorboard import SummaryWriter
import record_keeper as record_keeper_package
from pytorch_metric_learning import losses

record_writer = record_keeper_package.RecordWriter(your_folder_for_logs)
tensorboard_writer = SummaryWriter(log_dir=your_tensorboard_folder)
record_keeper = record_keeper_package.RecordKeeper(tensorboard_writer, record_writer, ["record_these"])

your_loss_dictionary = {"metric_loss": losses.ContrastiveLoss()}

# Then at each iteration of training:
record_keeper.update_records(your_loss_dictionary, current_iteration)

Now the attributes described in record_these, (specifically, num_non_zero_pos_pairs and num_non_zero_neg_pairs) can be viewed on Tensorboard.

nonzero_pairs_example

These data series are also saved in sqlite and CSV format. If you only want to use Tensorboard, then pass in only a SummaryWriter, and vice versa.

The dictionary that you pass into record_keeper.update_records can contain any number of objects, and for each one, RecordKeeper will check if the object has a "record_these" attribute. As long as you're making your dictionaries programmatically, it's possible to add large amounts of loggable data without clogging up your training code. See pytorch-metric-learning and powerful-benchmarker to see RecordKeeper in action.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

record-keeper-0.9.27.dev0.tar.gz (6.9 kB view details)

Uploaded Source

Built Distribution

record_keeper-0.9.27.dev0-py3-none-any.whl (7.9 kB view details)

Uploaded Python 3

File details

Details for the file record-keeper-0.9.27.dev0.tar.gz.

File metadata

  • Download URL: record-keeper-0.9.27.dev0.tar.gz
  • Upload date:
  • Size: 6.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0.post20191030 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.7.5

File hashes

Hashes for record-keeper-0.9.27.dev0.tar.gz
Algorithm Hash digest
SHA256 4f3aab6ab85633aa23f3fb25b57cd4f32680457e5ee27d45e07dfafe44680255
MD5 83def2364b2fe95b92d3b44e579b76f9
BLAKE2b-256 39f24d46b6154569a8a676f41f78f37b9eab5c1addb90c718d5f59289b5d3a65

See more details on using hashes here.

File details

Details for the file record_keeper-0.9.27.dev0-py3-none-any.whl.

File metadata

  • Download URL: record_keeper-0.9.27.dev0-py3-none-any.whl
  • Upload date:
  • Size: 7.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0.post20191030 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.7.5

File hashes

Hashes for record_keeper-0.9.27.dev0-py3-none-any.whl
Algorithm Hash digest
SHA256 917b79db3334c5b478e3bf023e4f2d5a0b3fa6027d09d44868baffce6c49bc34
MD5 f10d7e6f223fa22c7fca2236e9d25254
BLAKE2b-256 2bd05e99cff32499c56ed65669c11ee1443e6a0aa26476739825fb9521d20afc

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page