common

package
Version: v0.0.0-...-225e849 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2020 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package common provides common methods and tooling for the agents.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Retry

func Retry(attempts int, sleep time.Duration, callback func() error) (err error)

Retry callback function for the number of attempts sleeping for the duration in-between.

func WithDecayRate

func WithDecayRate(rate float32) func(*DecaySchedule)

WithDecayRate adds a decay rate to a default decay schedule.

func WithMinValue

func WithMinValue(rate float32) func(*DecaySchedule)

WithMinValue adds a minimum value rate to a default decay schedule.

Types

type ConstantSchedule

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

ConstantSchedule just returns a constant value.

func NewConstantSchedule

func NewConstantSchedule(value float32) *ConstantSchedule

NewConstantSchedule returns a new constant schedule.

func (*ConstantSchedule) Initial

func (c *ConstantSchedule) Initial() float32

Initial value.

func (*ConstantSchedule) Value

func (c *ConstantSchedule) Value() float32

Value for the given step.

type DecaySchedule

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

DecaySchedule returns values on an exponential decay means.

func DefaultDecaySchedule

func DefaultDecaySchedule(opts ...DecayScheduleOpt) *DecaySchedule

DefaultDecaySchedule is the default decay schedule.

func NewDecaySchedule

func NewDecaySchedule(decayRate, initialValue, minValue float32) *DecaySchedule

NewDecaySchedule returns a new DecaySchedule.

func (*DecaySchedule) Initial

func (d *DecaySchedule) Initial() float32

Initial value for the schedule.

func (*DecaySchedule) Value

func (d *DecaySchedule) Value() float32

Value for the given step. Will decay with each call.

type DecayScheduleOpt

type DecayScheduleOpt func(*DecaySchedule)

DecayScheduleOpt is an option for a decay schedule.

type LinearSchedule

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

LinearSchedule returns values on a linear means.

func DefaultLinearSchedule

func DefaultLinearSchedule(numTimesteps int) *LinearSchedule

DefaultLinearSchedule returns a linear schedule with some sensible defaults.

func NewLinearSchedule

func NewLinearSchedule(numTimesteps int, initialValue, finalValue float32) *LinearSchedule

NewLinearSchedule returns a new LinearSchedule.

func (*LinearSchedule) Initial

func (l *LinearSchedule) Initial() float32

Initial value for the schedule.

func (*LinearSchedule) Value

func (l *LinearSchedule) Value() float32

Value for the given step.

type Schedule

type Schedule interface {
	// Value for the given step.
	Value() float32

	// Initial value
	Initial() float32
}

Schedule is a means of transforming values based on timesteps.

Directories

Path Synopsis
Package num provides various numeric functions.
Package num provides various numeric functions.
Package op provides extended Gorgonia graph operations.
Package op provides extended Gorgonia graph operations.
Package require provides methods for enforcing requirements on values or exiting.
Package require provides methods for enforcing requirements on values or exiting.

Jump to

Keyboard shortcuts

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