def deserialize(self,
                 serialObjectDict=None,
                 fileName=None,
                 useCompression=False):
     import daal
     if fileName != None and serialObjectDict == None:
         bufferArray = np.load(fileName)
         buffArrObjName = open(fileName.rsplit(".", 1)[0] + ".txt",
                               "r").read()
     elif fileName == None and any(serialObjectDict):
         bufferArray = serialObjectDict["Array Object"]
         buffArrObjName = serialObjectDict["Object Information"]
     else:
         warnings.warn(
             'Expecting "bufferArray" or "fileName" argument, NOT both')
         raise SystemExit
     if useCompression == True:
         bufferArray = MultiSVM.decompress(self, bufferArray)
     dataArch = OutputDataArchive(bufferArray)
     try:
         deSerialObj = eval(buffArrObjName)
     except AttributeError:
         deSerialObj = HomogenNumericTable()
     deSerialObj.deserialize(dataArch)
     return deSerialObj
Пример #2
0
def deserializeNumericTable(buffer):

    #  Create a data archive to deserialize the numeric table
    dataArch = OutputDataArchive(buffer)

    #  Create a numeric table object
    dataTable = HomogenNumericTable()

    #  Deserialize the numeric table from the data archive
    dataTable.deserialize(dataArch)

    return dataTable
def broadcastWeightsAndBiasesToNodes(wb):

    wbBuffer = None
    # Serialize weights and biases on the root node
    if rankId == MPI_ROOT:
        if not wb:
            # Weights and biases table should be valid and not NULL on master
            return HomogenNumericTable()

        wbDataArch = InputDataArchive()
        wb.serialize(wbDataArch)
        wbBuffer = np.zeros(wbDataArch.getSizeOfArchive(), dtype=np.uint8)
        wbDataArch.copyArchiveToArray(wbBuffer)

    # Broadcast the serialized weights and biases
    wbBuffer = comm.bcast(wbBuffer)

    # Deserialize weights and biases
    wbDataArchLocal = OutputDataArchive(wbBuffer)

    wbLocal = HomogenNumericTable(ntype=np.float32)
    wbLocal.deserialize(wbDataArchLocal)

    return wbLocal