tfsum

package module
v0.0.0-...-0203575 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 24, 2017 License: BSD-3-Clause Imports: 9 Imported by: 2

README

Tensorflow provides golang api for model training and inference, however currently tensorboard is only supported when using python.

This repository enables using tensorboard with tensorflow golang api. tfsum.Writer writes file that tensorboard could understand.

Before using the following piece of code, you have to build tensorflow golang api: https://github.com/tensorflow/tensorflow/blob/master/tensorflow/go/README.md

Example

package main

import (
        "fmt"

        "github.com/helinwang/tfsum"
        tf "github.com/tensorflow/tensorflow/tensorflow/go"
)

func main() {
        step := 0
        w := &tfsum.Writer{Dir: "./tf-log", Name: "train"}
        var s *tf.Session
        var g *tf.Graph
        var input *tf.Tensor
        sum, err := s.Run(
                map[tf.Output]*tf.Tensor{
                        g.Operation("input").Output(0): input,
                },
                []tf.Output{
                        g.Operation("MergeSummary/MergeSummary").Output(0),
                },
                []*tf.Operation{
                        g.Operation("train_step"),
                })
        if err != nil {
                fmt.Println(err)
        }
        err = w.AddEvent(sum[0].Value().(string), int64(step))
        if err != nil {
                fmt.Println(err)
        }
}

Then run tensorboard normally

tensorboard --logdir=./tf-log

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Writer

type Writer struct {
	Dir  string
	Name string
	// contains filtered or unexported fields
}

Writer writes string of serialized tensorflow.Summary into file can be used for tensorboard

func (*Writer) AddEvent

func (w *Writer) AddEvent(s string, step int64) error

AddEvent adds a tensorflow.Summary event

func (*Writer) Close

func (w *Writer) Close()

Close closes file created by writer

Directories

Path Synopsis
tensorflow
core/framework
Package tensorflow is a generated protocol buffer package.
Package tensorflow is a generated protocol buffer package.
core/util
Package tensorflow is a generated protocol buffer package.
Package tensorflow is a generated protocol buffer package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL