Documentation ¶
Index ¶
- func CalEncGradientAndCost(rawPart *linear_vertical.RawLocalGradientPart, otherPartBytes []byte, ...) ([]byte, []byte, []*big.Int, *big.Int, error)
- func CalLocalGradientAndCost(trainSet *ml_common.TrainDataSet, thetas []float64, ...) (*linear_vertical.RawLocalGradientPart, []byte, [][]float64, error)
- func DeStandardizeOutput(params *pb_common.TrainModels, localPredict, otherPredict []float64) []float64
- func DecGradientAndCost(encGradsBytes []byte, encCostBytes []byte, privateKey *paillier.PrivateKey) ([]byte, []byte, error)
- func GetTrainDataSetFromFile(fileRows [][]string, params pb_common.TrainParams) (*ml_common.TrainDataSet, error)
- func InitThetas(trainSet *ml_common.TrainDataSet, params pb_common.TrainParams) []float64
- func PredictLocalPart(fileRows [][]string, params *pb_common.TrainModels) ([]float64, error)
- func StopTraining(lastCost, cost float64, params pb_common.TrainParams) bool
- func UpdateCost(decCostBytes []byte, costNoise *big.Int, params pb_common.TrainParams) (float64, error)
- func UpdateGradient(decGradBytes []byte, gradientNoise []*big.Int, thetas []float64, ...) ([]float64, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CalEncGradientAndCost ¶
func CalEncGradientAndCost(rawPart *linear_vertical.RawLocalGradientPart, otherPartBytes []byte, trainSet *ml_common.TrainDataSet, params pb_common.TrainParams, publicKeyBytes []byte, thetas []float64, round int) ([]byte, []byte, []*big.Int, *big.Int, error)
CalEncGradientAndCost calculate own encrypted gradient and cost, encrypted by other part's public key rawPart is calculated locally, otherPartBytes is received from other party publicKeyBytes is homomorphic public key bytes received from other party, used for encryption thetas is calculated in last round return encGradient, encCost, gradient noise, cost noise encGradient and encCost are mixed by noise, transferred to other party gradient noise and cost noise are plaintext, used to recover real gradient and cost
func CalLocalGradientAndCost ¶
func CalLocalGradientAndCost(trainSet *ml_common.TrainDataSet, thetas []float64, params pb_common.TrainParams, publicKey *paillier.PublicKey, round int) (*linear_vertical.RawLocalGradientPart, []byte, [][]float64, error)
CalLocalGradientAndCost calculate local gradient and cost part for tag/no-tag part trainSet is local train set, including features list and sample values publicKey is local public key for encrypting rawPart to encPart rawPart for local calculation for gradient and cost later, encPart for transfer
func DeStandardizeOutput ¶
func DeStandardizeOutput(params *pb_common.TrainModels, localPredict, otherPredict []float64) []float64
DeStandardizeOutput de-standardize predict sum to get real result de-standardizing requires average value and standard deviation of target feature only party with label can de-standardize predict sum
func DecGradientAndCost ¶
func DecGradientAndCost(encGradsBytes []byte, encCostBytes []byte, privateKey *paillier.PrivateKey) ([]byte, []byte, error)
DecGradientAndCost decrypt gradient list and cost for other part encGradsBytes and encCostBytes are ciphertext received from other party, encrypted by local homomorphic public key privateKey is local homomorphic private key, used to decrypt encGradsBytes and encCostBytes
func GetTrainDataSetFromFile ¶
func GetTrainDataSetFromFile(fileRows [][]string, params pb_common.TrainParams) (*ml_common.TrainDataSet, error)
GetTrainDataSetFromFile retrieve train dataset from file for tag/no-tag part fileRows is sample rows, first row is feature list, others are values for each sample params includes all required parameters for training
func InitThetas ¶
func InitThetas(trainSet *ml_common.TrainDataSet, params pb_common.TrainParams) []float64
InitThetas initialize model for tag/no-tag part
func PredictLocalPart ¶
func PredictLocalPart(fileRows [][]string, params *pb_common.TrainModels) ([]float64, error)
PredictLocalPart calculate predict values for local part fileRows is sample rows, first row is feature list, others are values for each sample
func StopTraining ¶
func StopTraining(lastCost, cost float64, params pb_common.TrainParams) bool
StopTraining determine if train process should be stopped
func UpdateCost ¶
func UpdateCost(decCostBytes []byte, costNoise *big.Int, params pb_common.TrainParams) (float64, error)
UpdateCost retrieve and update cost decCostBytes is decrypted cost received from other party, with costNoise
func UpdateGradient ¶
func UpdateGradient(decGradBytes []byte, gradientNoise []*big.Int, thetas []float64, params pb_common.TrainParams) ([]float64, error)
UpdateGradient retrieve and update thetas decGradBytes is decrypted gradient received from other party, with gradientNoise
Types ¶
This section is empty.