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

tanh_csr_batch.py

1 # file: tanh_csr_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 tanh 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 
34 utils_folder = os.path.realpath(os.path.abspath(os.path.dirname(os.path.dirname(__file__))))
35 if utils_folder not in sys.path:
36  sys.path.insert(0, utils_folder)
37 from utils import printNumericTable, createSparseTable
38 
39 # Input data set parameters
40 datasetName = os.path.join('..', 'data', 'batch', 'covcormoments_csr.csv')
41 
42 if __name__ == "__main__":
43 
44  # Read datasetFileName from a file and create a numeric table to store input data
45  dataTable = createSparseTable(datasetName)
46 
47  # Create an algorithm
48  algorithm = tanh.Batch(method=tanh.fastCSR)
49 
50  # Set an input object for the algorithm
51  algorithm.input.set(tanh.data, dataTable)
52 
53  # Compute Abs function
54  res = algorithm.compute()
55 
56  # Print the results of the algorithm
57  printNumericTable(res.get(tanh.value), "Hyperbolic Tangent result (first 5 rows):", 5)

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