zoukankan      html  css  js  c++  java
  • python daal test

    import os
    import sys
    
    from daal.algorithms import low_order_moments
    from daal.data_management import FileDataSource, DataSourceIface
    from daal.data_management import (readOnly, NumericTableIface, BlockDescriptor, BlockDescriptor_Float32, BlockDescriptor_Intc, packed_mask)
    
    #utils_folder = os.path.realpath(os.path.abspath(os.path.dirname(os.path.dirname(__file__))))
    #if utils_folder not in sys.path:
    #    sys.path.insert(0, utils_folder)
    #from utils import printNumericTable
    
    dataFileName = 'covcormoments_dense.csv'
    
    
    def getArrayFromNumericTable(data_table):
        num_rows = data_table.getNumberOfRows()
        num_cols = data_table.getNumberOfColumns()
        layout = data_table.getDataLayout()
        data_table_dict = data_table.getDictionary()
        try:
            # see # https://software.intel.com/sites/products/documentation/doclib/daal/daal-user-and-reference-guides/daal_cpp_api/data__utils_8h_source.htm
            # for numeral values of types
            data_type = data_table_dict[0].indexType
        except:
            data_type = 1 # default to Float64
    
        if data_type == 0:
            block = BlockDescriptor_Float32()
        elif data_type in [2, 4, 6, 8]:
            block = BlockDescriptor_Intc()
        else:
            block = BlockDescriptor() # Use Float64 by default
    
        data_table.getBlockOfRows(0, num_rows, readOnly, block)
        retValue = block.getArray()
        data_table.releaseBlockOfRows(block)
    
        return retValue
    
    
    
    
    def printResults(res):
    
         mi = getArrayFromNumericTable(res.get(low_order_moments.minimum))
         print (value of minimum:)
         print (mi)
    #    print(res.get(low_order_moments.minimum))
    #    print(res.get(low_order_moments.minimum))
    #    print(res.get(low_order_moments.maximum))
    #    print(res.get(low_order_moments.sum))
    #    print(res.get(low_order_moments.sumSquares))
    #    print(res.get(low_order_moments.sumSquaresCentered))
    #    print(res.get(low_order_moments.mean))
    #    print(res.get(low_order_moments.secondOrderRawMoment))
    #    print(res.get(low_order_moments.variance))
    #    print(res.get(low_order_moments.standardDeviation))
    #    print(res.get(low_order_moments.variation))
    
    if __name__ == "__main__":
    
        # Initialize FileDataSource to retrieve input data from .csv file
        dataSource = FileDataSource(
            dataFileName,
            DataSourceIface.doAllocateNumericTable,
            DataSourceIface.doDictionaryFromContext
        )
    
        # Retrieve the data from input file
        dataSource.loadDataBlock()
    
        # Create algorithm for computing low order moments in batch processing mode
        algorithm = low_order_moments.Batch()
    
        # Set input arguments of the algorithm
        algorithm.input.set(low_order_moments.data, dataSource.getNumericTable())
    
        # Get computed low order moments
        res = algorithm.compute()
    
        printResults(res)
    

      

  • 相关阅读:
    51单片机学习笔记(清翔版)(23)——红外通讯
    51单片机学习笔记(清翔版)(22)——数字温度传感器DS18B20
    信号与系统1.1.4信号的分类-信号的MATLAB的表示与绘图
    信号与系统1.1.3信号的分类-能量与功率信号,因果与反因果
    信号与系统1.1.2信号的分类-周期与非周期
    信号与系统1.1.1信号的分类-确定与随机-离散与连续
    51单片机学习笔记(清翔版)(21)——ADDA数模转换
    51单片机学习笔记(清翔版)(19)——串口通信
    ecplise问题总结
    Android广播机制(转)
  • 原文地址:https://www.cnblogs.com/bonelee/p/9877973.html
Copyright © 2011-2022 走看看