Python* API Reference for Intel® Data Analytics Acceleration Library 2020 Update 1

tanh_dense_batch.py

1 # file: tanh_dense_batch.py
2 #===============================================================================
3 # Copyright 2014-2020 Intel Corporation
4 #
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
8 #
9 # http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16 #===============================================================================
17 
18 #
19 # ! Content:
20 # ! Python example of Hyperbolic tangent algorithm.
21 # !
22 # !*****************************************************************************
23 
24 #
25 
26 
27 #
28 
29 import os
30 import sys
31 
32 import daal.algorithms.math.tanh as tanh
33 from daal.data_management import FileDataSource, DataSourceIface
34 
35 utils_folder = os.path.realpath(os.path.abspath(os.path.dirname(os.path.dirname(__file__))))
36 if utils_folder not in sys.path:
37  sys.path.insert(0, utils_folder)
38 from utils import printNumericTable
39 
40 # Input data set parameters
41 datasetName = os.path.join('..', 'data', 'batch', 'covcormoments_dense.csv')
42 
43 if __name__ == "__main__":
44 
45  # Retrieve the input data
46  dataSource = FileDataSource(datasetName,
47  DataSourceIface.doAllocateNumericTable,
48  DataSourceIface.doDictionaryFromContext)
49  dataSource.loadDataBlock()
50 
51  # Create an algorithm
52  algorithm = tanh.Batch()
53 
54  # Set an input object for the algorithm
55  algorithm.input.set(tanh.data, dataSource.getNumericTable())
56 
57  # Compute Hyperbolic tangent function
58  res = algorithm.compute()
59 
60  # Print the results of the algorithm
61  printNumericTable(res.get(tanh.value), "Tanh result (first 5 rows):", 5)

For more complete information about compiler optimizations, see our Optimization Notice.