Skip to content
forked from helinwang/tfsum

Enable TensorBoard for TensorFlow Go API

License

Notifications You must be signed in to change notification settings

zx84289061/tfsum

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Enable TensorBoard for TensorFlow Go API

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 100.0%