web

package
v0.0.0-...-c5f678a Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2019 License: GPL-3.0 Imports: 32 Imported by: 0

Documentation

Overview

Package web has a web based interface we network training and visualisation.

Index

Constants

This section is empty.

Variables

View Source
var AssetDir = os.Getenv("GOPATH") + "/src/github.com/jnb666/deepthought2/assets"
View Source
var ErrMissingField = errors.New("value is required")
View Source
var ErrNotFound = errors.New("page not found")

Functions

func SaveNetwork

func SaveNetwork(data *NetworkData, reset bool) error

Encode data in gob format and save to file under nnet.DataDir

Types

type ConfigPage

type ConfigPage struct {
	*Templates
	Fields     []Field
	Layers     []Layer
	TuneFields []Field
	// contains filtered or unexported fields
}

func NewConfigPage

func NewConfigPage(t *Templates, net *Network) *ConfigPage

Base data for handler functions to view and update the network config

func (*ConfigPage) Base

func (p *ConfigPage) Base() func(w http.ResponseWriter, r *http.Request)

Handler function for the config template

func (*ConfigPage) Load

func (p *ConfigPage) Load() func(w http.ResponseWriter, r *http.Request)

Handler function for the action to load a new model

func (*ConfigPage) Reset

func (p *ConfigPage) Reset() func(w http.ResponseWriter, r *http.Request)

Handler function for the config form save action

func (*ConfigPage) Save

func (p *ConfigPage) Save() func(w http.ResponseWriter, r *http.Request)

Handler function for the config form save action

func (*ConfigPage) Tune

func (p *ConfigPage) Tune() func(w http.ResponseWriter, r *http.Request)

Handler function for the tune form

type Field

type Field struct {
	Name    string
	Value   string
	Error   string
	Boolean bool
	Options []string
}

type HistoryData

type HistoryData struct {
	Stats nnet.Stats
	Conf  nnet.Config
}

type HistoryRow

type HistoryRow struct {
	Id      int
	Params  template.HTML
	Runs    int
	Stats   []string
	Color   string
	Enabled bool
}

type ImagePage

type ImagePage struct {
	*Templates
	Dset    string
	Class   int
	Page    int
	Errors  bool
	Distort string
	Rows    []int
	Cols    []int
	Width   int
	Height  int
	Pages   int
	Total   int
	// contains filtered or unexported fields
}

func NewImagePage

func NewImagePage(t *Templates, net *Network, rows, cols, height, width int) *ImagePage

Base data for handler functions to view input image dataset

func (*ImagePage) Base

func (p *ImagePage) Base() func(w http.ResponseWriter, r *http.Request)

Handler function for the main image page

func (*ImagePage) Grid

func (p *ImagePage) Grid() func(w http.ResponseWriter, r *http.Request)

Handler function for the frame with grid of images

func (*ImagePage) Image

func (p *ImagePage) Image() func(w http.ResponseWriter, r *http.Request)

Handler function for the image data

func (*ImagePage) Index

func (p *ImagePage) Index(row, col int) int

func (*ImagePage) Label

func (p *ImagePage) Label(i int) (l LabelInfo)

func (*ImagePage) Setopt

func (p *ImagePage) Setopt() func(w http.ResponseWriter, r *http.Request)

Set option from top menu

func (*ImagePage) Url

func (p *ImagePage) Url(i int) string

type LabelInfo

type LabelInfo struct {
	Desc  string
	Pred  string
	Class string
}

type Layer

type Layer struct {
	Index  int
	Desc   string
	Shape  string
	Prefix template.HTML
}

type LayerData

type LayerData struct {
	LayerId string
	WeightV []uint32
}

type LayerInfo

type LayerInfo struct {
	Desc      string
	Image     []string
	Values    []template.HTML
	Cols      int
	Width     int
	CellWidth int
	PadWidth  int
	Class     string
}
type Link struct {
	Url      string
	Name     string
	Selected bool
	Submit   bool
}

type Network

type Network struct {
	*NetworkData
	*nnet.Network
	Data   map[string]nnet.Data
	Labels map[string][]int32

	sync.Mutex
	// contains filtered or unexported fields
}

Network and associated training / test data and configuration

func NewNetwork

func NewNetwork(model string) (*Network, error)

Create a new network and load config from data given model name

func (*Network) Export

func (n *Network) Export()

Export current state prior to saving to file

func (*Network) Import

func (n *Network) Import()

Import current state after loading from file

func (*Network) Init

func (n *Network) Init(conf nnet.Config) error

Initialise the network

func (*Network) Queue

func (n *Network) Queue() num.Queue

func (*Network) Start

func (n *Network) Start(conf nnet.Config, lock bool) error

Initialise for new training run

func (*Network) Train

func (n *Network) Train(restart bool) error

Perform training run

type NetworkData

type NetworkData struct {
	Model   string
	Conf    nnet.Config
	MaxRun  int
	Run     int
	Epoch   int
	Stats   []nnet.Stats
	Pred    map[string][]int32
	Params  []LayerData
	History []HistoryData
	Tuners  []TuneParams
}

Embedded structs used to persist state to file

func LoadNetwork

func LoadNetwork(model string, reset bool) (data *NetworkData, err error)

Read back gob encoded data file, if not found or reset is set then load default config.

type Templates

type Templates struct {
	*template.Template
	Menu     []Link
	Options  []Link
	Dropdown []Link
	Toplevel bool
	WSRoot   string
	Heading  template.HTML
	Frame    string
	Error    string
}

Template and main menu definition

func NewTemplates

func NewTemplates(ssl bool) (*Templates, error)

Load and parse templates and initialise main menu

func (*Templates) AddMenuItem

func (t *Templates) AddMenuItem(url, name string) *Templates

func (*Templates) AddOption

func (t *Templates) AddOption(l Link) *Templates

func (*Templates) Clone

func (t *Templates) Clone() *Templates

func (*Templates) ErrorHandler

func (t *Templates) ErrorHandler(status int, errorText error) http.Handler

Return custom error response

func (*Templates) Exec

func (t *Templates) Exec(w http.ResponseWriter, name string, data interface{}, topLevel bool) error

Execute given template and write it to the client

func (*Templates) MenuSelected

func (t *Templates) MenuSelected(name string) bool

func (*Templates) OptionSelected

func (t *Templates) OptionSelected(name string) bool

func (*Templates) Select

func (t *Templates) Select(url string) *Templates

func (*Templates) SelectOptions

func (t *Templates) SelectOptions(names []string) *Templates

func (*Templates) ToggleOption

func (t *Templates) ToggleOption(name string) bool

type TrainPage

type TrainPage struct {
	*Templates
	Plots      []template.HTML
	PlotWidth  int
	PlotHeight int
	// contains filtered or unexported fields
}

func NewTrainPage

func NewTrainPage(t *Templates, net *Network) *TrainPage

Base data for handler functions to perform network training and display the stats

func (*TrainPage) Base

func (p *TrainPage) Base(url, frame string) func(w http.ResponseWriter, r *http.Request)

Handler function for the train base template

func (*TrainPage) Command

func (p *TrainPage) Command() func(w http.ResponseWriter, r *http.Request)

Handler function for the train command options

func (*TrainPage) Filter

func (p *TrainPage) Filter() func(w http.ResponseWriter, r *http.Request)

Handler function for the form to filter the stats values

func (*TrainPage) History

func (p *TrainPage) History() []HistoryRow

func (*TrainPage) HistoryHeaders

func (p *TrainPage) HistoryHeaders() []string

func (*TrainPage) LatestStats

func (p *TrainPage) LatestStats() []nnet.Stats

func (*TrainPage) Setopt

func (p *TrainPage) Setopt() func(w http.ResponseWriter, r *http.Request)

Handler function to toggle options

func (*TrainPage) Stats

func (p *TrainPage) Stats(history bool) func(w http.ResponseWriter, r *http.Request)

Handler function for the stats frame

func (*TrainPage) StatsHeaders

func (p *TrainPage) StatsHeaders() []string

func (*TrainPage) Websocket

func (p *TrainPage) Websocket() func(w http.ResponseWriter, r *http.Request)

Handler function for websocket connection

type TuneParams

type TuneParams struct {
	Name    string
	Values  []string
	Boolean bool
}

type ViewPage

type ViewPage struct {
	*Templates
	Page    string
	Input   LayerInfo
	Output  LayerInfo
	Layers  []LayerInfo
	Columns int
	// contains filtered or unexported fields
}

func NewViewPage

func NewViewPage(t *Templates, net *Network) *ViewPage

Base data for handler functions to view network activations and weights

func (*ViewPage) Base

func (p *ViewPage) Base() func(w http.ResponseWriter, r *http.Request)

Handler function for the main view page

func (*ViewPage) Image

func (p *ViewPage) Image() func(w http.ResponseWriter, r *http.Request)

Handler function to generate the image for the output and weight data visualisation

func (*ViewPage) Network

func (p *ViewPage) Network() func(w http.ResponseWriter, r *http.Request)

Handler function for the frame with activation or weights visualisation

func (*ViewPage) Setopt

func (p *ViewPage) Setopt() func(w http.ResponseWriter, r *http.Request)

Set option from top menu

Jump to

Keyboard shortcuts

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