docs/apis/PSModel_en.md
PSModel is Angel's core abstract class. It encapsulates details of context and client of remote parameter server (PS) and provides frequently-use interfaces for accessing and updating remote matrices and vectors, allows algorithm engineers to operate on distributed matrices and vectors on the PS as if operating on local objects. PSModel is a mutable model object that can be updated iteratively in essence.
PSModel has three core classes: MatrixContext,MatrixClient,TaskContext, with which you can make any operation on remote PS possible.
For developing machine-learning algorithms on Angel, we recommend creating PSModel inside MLModel and working on top of it. PSModel has the following five major interfaces:
With decent ways of initializing PSModel, setting PSModel's behavioral properties and calling PSModel methods, algorithm engineers can operate on remote distributed model (martrix or vector). As the core abstract class, PSModel allows one to program machine-learning algorithms in distributed fashion without caring about low-level details.
constructor
def apply[K <: TVector](modelName: String, row: Int, col: Int, blockRow: Int = -1, blockCol: Int = -1)(implicit ctx:TaskContext)getRow
def getRow(rowId: Int): KgetRows
def getRows(rowIndexes:Array[Int]): List[K]getRow methodgetRowsFlow
def getRowsFlow(rowIndex: RowIndex, batchNum: Int): GetRowsResultgetRow under the BSP/SSP/ASP protocolsget
def get(func: GetFunc): GetResultpsf get function to get matrix elements or their statistics. Different from getRow/getRows/getRowsFlow, this method only supports ASPpsf getincrement
def increment(delta: TVector)flush or clockincrement
def increment(deltas: List[TVector])flush or clockupdate
def update(func: UpdaterFunc): Future[VoidResult]psf update function to update the parameter matrix. Unlike the increment method, this method directly pushes delta to PSpsf update function. For a detailed introduction to psf function, please refer to psFunc Developing Guide. Users can customize the psf update function. Angel also provides an update lib of commonly-used functions. Unlike the increment methods, this method immediately pushes the delta to the PSsyncClock
def syncClock():clock
def clock(): Future[VoidResult]increment) and send to the PS, then update the matrix clockclock operation result; the application can choose whether to wait for clock operation to completeflush
def flush(): Future[VoidResult]increment) and send to the PSflush operation result; the application can choose whether to wait for flush to completesetLoadPath
def setLoadPath(path: String)predict mode --- PS loads the matrix of parameters from file for initializationsetSavePath
def setSavePath(path: String)train mode, when training is done, the matrix on PS needs to be saved in the file systemsetAverage
def setAverage(aver: Boolean)increment method, but not affecting the update functionssetHogwild
def setHogwild(hogwild: Boolean)setRowType
def setRowType(rowType: MLProtos.RowType)rowType: MLProtos.RowType, currently support
Users can choose the most memory-efficient setting based on their own use cases.
setOplogType
def setOplogType(oplogType: String)increment, Angel caches delta in local by creating a local matrix of the same size as the matrix to be updatedsetAttribute
def setAttribute(key: String, value: String)