Coder Social home page Coder Social logo

tensorboard-chainer's Introduction

Build Status codecov

Code Climate

PyPI version

tensorboard-chainer

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

This is based on tensorboard-pytorch.

Usage

Install tensorflow.

pip install tensorflow

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

cd examples
python demo.py
tensorboard --logdir runs

Scalar example

graph

Histogram example

graph

Graph example

graph

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

    @within_name_scope('MLP')
    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)),
            chainer.Variable(np.random.rand(1).astype(np.int32)))

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

writer.close()

Reference

tensorboard-chainer's People

Contributors

lanpa avatar neka-nat avatar raahii avatar stonesjtu avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.