Skip to main content

Log TensorBoard events with chainer

Project description

Build Status codecov

Code Climate

PyPI version


Write tensorboard events with simple command. including scalar, image, histogram, audio, text, graph and embedding.

This is based on tensorboard-pytorch.


Install tensorflow.

pip install tensorflow

Execute and tensorboard. Access "localhost:6006" in your browser.

cd examples
tensorboard --logdir runs

Scalar example


Histogram example


Graph example


Name scope

Like tensorflow, nodes in the graph can be grouped together in the namespace to make it easy to see.

import chainer
import chainer.functions as F
import chainer.links as L
from tb_chainer import name_scope, within_name_scope

class MLP(chainer.Chain):
    def __init__(self, n_units, n_out):
        super(MLP, self).__init__()
        with self.init_scope():
            self.l1 = L.Linear(None, n_units)  # n_in -> n_units
            self.l2 = L.Linear(None, n_units)  # n_units -> n_units
            self.l3 = L.Linear(None, n_out)  # n_units -> n_out

    def __call__(self, x):
        with name_scope('linear1', self.l1.params()):
            h1 = F.relu(self.l1(x))
        with name_scope('linear2', self.l2.params()):
            h2 = F.relu(self.l2(h1))
        with name_scope('linear3', self.l3.params()):
            o = self.l3(h2)
        return o

How to save the logs using this model is shown below. add_all_variable_images is the function that saves the Variable's data in the model that matches the pattern as an images. add_all_parameter_histograms is the function that save histograms of the Parameter's data in the model that match the pattern.

from datetime import datetime
from tb_chainer import SummaryWriter

model = L.Classifier(MLP(1000, 10))

res = model(chainer.Variable(np.random.rand(1, 784).astype(np.float32)),

writer = SummaryWriter('runs/''%B%d  %H:%M:%S'))
writer.add_all_variable_images([res], pattern='.*MLP.*')
writer.add_all_parameter_histograms([res], pattern='.*MLP.*')



Project details

Download files

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

Files for tensorboard-chainer, version 0.5.3
Filename, size File type Python version Upload date Hashes
Filename, size tensorboard-chainer-0.5.3.tar.gz (32.0 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page