Deprecation Notice: With the introduction of daal4py, a package that supersedes PyDAAL, Intel is deprecating PyDAAL and will discontinue support starting with Intel® DAAL 2021 and Intel® Distribution for Python 2021. Until then Intel will continue to provide compatible pyDAAL pip and conda packages for newer releases of Intel DAAL and make it available in open source. However, Intel will not add the new features of Intel DAAL to pyDAAL. Intel recommends developers switch to and use daal4py.
Note: To find daal4py examples, refer to daal4py documentation or browse github repository.
30 from daal.algorithms.neural_networks
import layers
31 from daal.algorithms.neural_networks
import initializers
32 from daal.data_management
import HomogenTensor, TensorIface
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 printTensor
39 if __name__ ==
"__main__":
42 tensorData = HomogenTensor(inDims, TensorIface.doAllocate)
46 truncatedGaussInitializer = initializers.truncated_gaussian.Batch(0.0, 1.0)
49 truncatedGaussInitializer.input.set(initializers.data, tensorData)
52 truncatedGaussInitializer.compute()
55 printTensor(tensorData,
"Data with truncated gaussian distribution:")
60 gaussInitializer = initializers.gaussian.Batch(1.0, 0.5)
63 gaussInitializer.input.set(initializers.data, tensorData)
66 gaussInitializer.compute()
69 printTensor(tensorData,
"Data with gaussian distribution:")
74 uniformInitializer = initializers.uniform.Batch(-5.0, 5.0)
77 uniformInitializer.input.set(initializers.data, tensorData)
80 uniformInitializer.compute()
83 printTensor(tensorData,
"Data with uniform distribution:")
88 fullyconnectedLayerForward = layers.fullyconnected.forward.Batch(5)
91 fullyconnectedLayerForward.input.setInput(layers.forward.data, tensorData)
92 fullyconnectedLayerForward.parameter.weightsInitializer = initializers.xavier.Batch()
95 fullyconnectedLayerForward.compute()
98 printTensor(fullyconnectedLayerForward.input.getInput(layers.forward.weights),
"Weights filled by xavier initializer:")