learners

package
v0.0.0-...-ebe581b Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Learner

type Learner interface {
	// Advance does calculation with local data and communicates with other nodes in cluster to train a model step by step
	// When we implement the method, we should pay attention to performance in case it takes a long time and blocks the client.
	// payload could be resolved by Learner defined by specific algorithm
	Advance(payload []byte) (*pb.TrainResponse, error)
}

Learner is assigned with a specific algorithm and data used for training a model participates in the multi-parts-calculation during training process

func NewLearner

func NewLearner(id string, address string, algo pbCom.Algorithm,
	params *pbCom.TrainParams, samplesFile []byte,
	parties []string, paddleFLParams *pbCom.PaddleFLParams, rpc RpcHandler, rh ResultHandler, le LiveEvaluator) (Learner, error)

NewLearner returns a Learner defined by algorithm and training samples id is the assigned id for Learner address indicates local mpc-node algo is the assigned algorithm for learner parties are other learners who participates in MPC, assigned with mpc-node address usually rpc is used to request remote mpc-node rh handles final result which is successful or failed params are parameters for training model samplesFile contains samples for training model le is an LiveEvaluator, and LiveEvaluation should be performed by learner if it is assigned without nil

func NewLearnerWithoutSamples

func NewLearnerWithoutSamples(id string, address string, algo pbCom.Algorithm,
	params *pbCom.TrainParams,
	parties []string, paddleFLParams *pbCom.PaddleFLParams, rpc RpcHandler, rh ResultHandler) (Learner, error)

NewLearner returns a Learner defined by algorithm and training samples, but doesn't run it id is the assigned id for Learner address indicates local mpc-node algo is the assigned algorithm for learner parties are other learners who participates in MPC, assigned with mpc-node address usually rpc is used to request remote mpc-node rh handles final result which is successful or failed params are parameters for training model

type LiveEvaluator

type LiveEvaluator interface {
	// Trigger triggers model evaluation.
	// The parameter contains two types of messages.
	// One is to set the learner for evaluation with training set and start it.
	// The other is to drive the learner to continue training. When the conditions are met(reaching pause round),
	// stop training and instantiate the model for validation.
	Trigger(*pb.LiveEvaluationTriggerMsg) error
}

LiveEvaluator performs staged evaluation during training. The basic steps of LiveEvaluator:

Divide the dataset in the way of proportional random division.
Initiate a learner for evaluation with training part.
Train the model, and pause training when the pause round is reached,
and instantiate the staged model for validation,
then, calculate the evaluation metric scores with prediction result obtained on the validation set.
Repeat Train-Pause-validate until the stop signal is received.

type ResultHandler

type ResultHandler interface {
	SaveResult(*pbCom.TrainTaskResult)
}

ResultHandler handles final result which is successful or failed Should be called when learning finished

type RpcHandler

type RpcHandler interface {
	StepTrain(req *pb.TrainRequest, peerName string) (*pb.TrainResponse, error)
	// StepTrainWithRetry sends training message to remote mpc-node
	// retries 2 times at most
	// inteSec indicates the interval between retry requests, in seconds
	StepTrainWithRetry(req *pb.TrainRequest, peerName string, times int, inteSec int64) (*pb.TrainResponse, error)
}

RpcHandler used to request remote mpc-node

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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