Git Product home page Git Product logo

tfsum's Introduction

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

tfsum's People

Contributors

helinwang avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

tfsum's Issues

this version is not match tf 2.0, can anybody help?

panic: proto: message tensorflow.AllocationDescription is already registered
See https://developers.google.com/protocol-buffers/docs/reference/go/faq#namespace-conflict

goroutine 1 [running]:
google.golang.org/protobuf/reflect/protoregistry.glob..func1(0x1832fc0, 0xc013db5520, 0x17f74a0, 0xc013eac630, 0x154e900)
/home/go/pkg/mod/google.golang.org/[email protected]/reflect/protoregistry/registry.go:54 +0x24c
google.golang.org/protobuf/reflect/protoregistry.(*Types).register(0xc000202630, 0x157ff8c, 0x7, 0x1832fc0, 0xc013db5520, 0x154e900, 0xc013eab8c0, 0x9c2545, 0x1841540)
/home/go/pkg/mod/google.golang.org/[email protected]/reflect/protoregistry/registry.go:566 +0x33b
google.golang.org/protobuf/reflect/protoregistry.(*Types).RegisterMessage(0xc000202630, 0x1821f80, 0xc013eab8c0, 0x0, 0x0)
/home/go/pkg/mod/google.golang.org/[email protected]/reflect/protoregistry/registry.go:493 +0xf5
github.com/golang/protobuf/proto.RegisterType(0x1816340, 0x0, 0x15a3e93, 0x20)
/home/go/pkg/mod/github.com/golang/[email protected]/proto/registry.go:181 +0x71
github.com/helinwang/tfsum/tensorflow/core/framework.init.0()
/home/go/pkg/mod/github.com/helinwang/[email protected]/tensorflow/core/framework/allocation_description.pb.go:149 +0x4b

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.