theano 安装_Theano-安装

theano 安装_Theano-安装_第1张图片

theano 安装

Theano-安装 (Theano - Installation)

Theano can be installed on Windows, MacOS, and Linux. The installation in all the cases is trivial. Before you install Theano, you must install its dependencies. The following is the list of dependencies −

Theano可以安装在Windows,MacOS和Linux上。 在所有情况下,安装都很简单。 在安装Theano之前,必须安装其依赖项。 以下是依赖项列表-

  • Python

    Python
  • NumPy − Required

    NumPy-必需
  • SciPy − Required only for Sparse Matrix and special functions

    SciPy-仅对于稀疏矩阵和特殊功能是必需的
  • BLAS − Provides standard building blocks for performing basic vector and matrix operations

    BLAS-提供用于执行基本矢量和矩阵运算的标准构件

The optional packages that you may choose to install depending on your needs are −

您可以根据需要选择安装的可选软件包是-

  • nose: To run Theano’s test-suite

    鼻子:经营Theano的测试套件
  • Sphinx − For building documentation

    Sphinx-用于建筑文档
  • Graphiz and pydot − To handle graphics and images

    Graphiz和pydot-处理图形和图像
  • NVIDIA CUDA drivers − Required for GPU code generation/execution

    NVIDIA CUDA驱动程序-GPU代码生成/执行必需
  • libgpuarray − Required for GPU/CPU code generation on CUDA and OpenCL devices

    libgpuarray-在CUDA和OpenCL设备上生成GPU / CPU代码所必需

We shall discuss the steps to install Theano in MacOS.

我们将讨论在MacOS中安装Theano的步骤。

MacOS安装 (MacOS Installation)

To install Theano and its dependencies, you use pip from the command line as follows. These are the minimal dependencies that we are going to need in this tutorial.

要安装Theano及其依赖项,请在命令行中使用pip ,如下所示。 这些是我们在本教程中需要的最小依赖关系。


$ pip install Theano
$ pip install numpy
$ pip install scipy
$ pip install pydot

You also need to install OSx command line developer tool using the following command −

您还需要使用以下命令安装OSx命令行开发人员工具-


$ xcode-select --install

You will see the following screen. Click on the Install button to install the tool.

您将看到以下屏幕。 单击安装按钮以安装该工具。

theano 安装_Theano-安装_第2张图片

On successful installation, you will see the success message on the console.

成功安装后,您将在控制台上看到成功消息。

测试安装 (Testing the Installation)

After the installation completes successfully, open a new notebook in the Anaconda Jupyter. In the code cell, enter the following Python script −

安装成功完成后,在Anaconda Jupyter中打开一个新笔记本。 在代码单元中,输入以下Python脚本-

(Example)


import theano
from theano import tensor
a = tensor.dscalar()
b = tensor.dscalar()
c = a + b
f = theano.function([a,b], c)
d = f(1.5, 2.5)
print (d)

输出量 (Output)

Execute the script and you should see the following output −

执行脚本,您应该看到以下输出-


4.0

The screenshot of the execution is shown below for your quick reference −

执行的屏幕截图如下所示,供您快速参考-

theano 安装_Theano-安装_第3张图片

If you get the above output, your Theano installation is successful. If not, follow the debug instructions on Theano download page to fix the issues.

如果获得上述输出,则表明Theano安装成功。 如果不是,请按照Theano下载页面上的调试说明修复问题。

什么是Theano? (What is Theano?)

Now that you have successfully installed Theano, let us first try to understand what is Theano? Theano is a Python library. It lets you define, optimize, and evaluate mathematical expressions, especially the ones which are used in Machine Learning Model development. Theano itself does not contain any pre-defined ML models; it just facilitates its development. It is especially useful while dealing with multi-dimensional arrays. It seamlessly integrates with NumPy, which is a fundamental and widely used package for scientific computations in Python.

现在您已经成功安装了Theano,让我们首先尝试了解什么是Theano? Theano是一个Python库。 它使您可以定义,优化和评估数学表达式,尤其是在机器学习模型开发中使用的那些数学表达式。 Theano本身不包含任何预定义的ML模型; 它只是促进其发展。 在处理多维数组时特别有用。 它与NumPy无缝集成,NumPy是Python中用于科学计算的基本且广泛使用的软件包。

Theano facilitates defining mathematical expressions used in ML development. Such expressions generally involve Matrix Arithmetic, Differentiation, Gradient Computation, and so on.

Theano有助于定义ML开发中使用的数学表达式。 这样的表达式通常涉及矩阵算术,微分,梯度计算等。

Theano first builds the entire Computational Graph for your model. It then compiles it into highly efficient code by applying several optimization techniques on the graph. The compiled code is injected into Theano runtime by a special operation called function available in Theano. We execute this function repetitively to train a neural network. The training time is substantially reduced as compared to using pure Python coding or even a full C implementation.

Theano首先为您的模型构建整个计算图。 然后,通过在图形上应用多种优化技术,将其编译为高效代码。 已编译的代码通过Theano中可用的称为function的特殊操作注入Theano运行时中。 我们重复执行此功能以训练神经网络。 与使用纯Python编码甚至是完整的C实现相比,培训时间大大减少了。

We shall now understand the process of Theano development. Let us begin with how to define a mathematical expression in Theano.

现在我们将了解Theano开发的过程。 让我们从如何在Theano中定义数学表达式开始。

翻译自: https://www.tutorialspoint.com/theano/theano_installation.htm

theano 安装

你可能感兴趣的:(python,深度学习,机器学习,人工智能,java)