dual

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2021 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Float = G.Float32

Functions

func Train

func Train(d *Dual, Xs, policies, values *tensor.Dense, batches, iterations int) error

Train is a basic trainer.

Types

type Config

type Config struct {
	K            int     // number of filters
	SharedLayers int     // number of shared residual blocks
	FC           int     // fc layer width
	L2           float64 // L2 regularization

	BatchSize     int // batch size
	Width, Height int // board size
	Features      int // feature counts

	ActionSpace int
	FwdOnly     bool // is this a fwd only graph?
}

Config configures the neural network

func DefaultConf

func DefaultConf(m, n, actionSpace int) Config

func (Config) IsValid

func (conf Config) IsValid() bool

type Dual

type Dual struct {
	Config

	Π, V *G.Node // pi and value labels. Pi is a matrix of 1s and 0s
	// contains filtered or unexported fields
}

Dual is the whole neural network architecture of the dual network.

The policy and value outputs are shared

func New

func New(conf Config) *Dual

New returns a new, uninitialized *Dual.

func (*Dual) Clone

func (d *Dual) Clone() (*Dual, error)

func (*Dual) Dual

func (d *Dual) Dual() *Dual

Dual implemented Dualer

func (*Dual) GobDecode

func (d *Dual) GobDecode(p []byte) error

func (*Dual) GobEncode

func (d *Dual) GobEncode() (retVal []byte, err error)

func (*Dual) Init

func (d *Dual) Init() error

func (*Dual) Model

func (d *Dual) Model() G.Nodes

func (*Dual) SetTesting

func (d *Dual) SetTesting()

type Inferencer

type Inferencer struct {
	// contains filtered or unexported fields
}

Inferencer is a struct that holds the state for a *Dual and a VM. By using an Inferece struct, there is no longer a need to create a VM every time an inference needs to be done.

func Infer

func Infer(d *Dual, actionSpace int, toLog bool) (*Inferencer, error)

Infer takes a trained *Dual, and creates a interence data structure such that it'd be easy to infer

func (*Inferencer) Close

func (m *Inferencer) Close() error

Close implements a closer, because well, a gorgonia VM is a resource.

func (*Inferencer) Dual

func (m *Inferencer) Dual() *Dual

Dual implements Dualer

func (*Inferencer) ExecLog

func (m *Inferencer) ExecLog() string

ExecLog returns the execution log. If Infer was called with toLog = false, then it will return an empty string

func (*Inferencer) Infer

func (m *Inferencer) Infer(board []float32) (policy []float32, value float32, err error)

Infer takes the board, in form of a []float32, and runs inference, and returns the value

Jump to

Keyboard shortcuts

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