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)
    

      

  • 相关阅读:
    win8 vs2010 openni2 配置
    写一个程序,分析一个文本文件(英文文章)中各个词出现的频率,并且把频率最高的十个词打印出来。
    电梯调度
    new 一个button 然后dispose,最后这个button是null吗???
    org.apache.hadoop.security.AccessControlException
    算法导论第二章、插入排序
    算法导论第六章、堆排序
    算法导论第八章、计数排序
    观后感
    第二次随笔
  • 原文地址:https://www.cnblogs.com/bonelee/p/9877973.html
Copyright © 2011-2022 走看看