Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/helinwang/tfsum

Enable TensorBoard for TensorFlow Go API
https://github.com/helinwang/tfsum

golang tensorboard tensorboard-visualizations tensorflow

Last synced: 8 days ago
JSON representation

Enable TensorBoard for TensorFlow Go API

Awesome Lists containing this project

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
```