---
title: 运行和验证
description: "1. 使用PuTTY工具，以root用户登录服务器。"
url: https://www.hikunpeng.com/document/detail/zh/kunpenghpcs/hpcindapp/prtg-osc/kunpengtheano_02_0009.html
sourcePath: /source/zh/kunpenghpcs/hpcindapp/prtg-osc/kunpengtheano_02_0009.html
indexId: 6d798f875084f8c2a480c5afcabe5f79993d0eda171f46fb1829215c70fd4cc668
---
# 运行和验证

#### 操作步骤

1. 使用PuTTY工具，以root用户登录服务器。
2. 执行以下命令创建测试文件test.py。

  a. 新建“test.py”文件。

```
vim test.py
```


  b. 按“i”进入编辑模式，在文件中输入以下内容。

```
import theano
from theano import tensor
##declare two symbolic floating-point scalars
a = tensor.dscalar()
b = tensor.dscalar()
##create a simple expression
c = a + b
##convert the expression into a callable object that takes (a,b)
##values as input and computes a value for c
f = theano.function([a,b], c)
##bind 1.5 to ‘a’, 2.5 to ‘b’, and evaluate ‘c’
assert 4.0 == f(1.5, 2.5)
```


  c. 按“Esc”键，输入:wq!，按“Enter”保存并退出编辑。
3. 执行以下命令测试。

```
python3 test.py
```


  运行的示例不提供任何输出，则证明结论1.5+2.5=4.0是真实的。

4. 执行以下命令创建测试文件test2.py。

  a. 新建“test2.py”文件。

```
vim test2.py
```


  b. 按“i”进入编辑模式，在文件中输入以下内容。

```
import theano
from theano import tensor
##declare two symbolic floating-point scalars
a = tensor.dscalar()
b = tensor.dscalar()
##create a simple expression
c = a + b
##convert the expression into a callable object that takes (a,b)
##values as input and computes a value for c
f = theano.function([a,b], c)
##bind 1.5 to ‘a’, 2.5 to ‘b’, and evaluate ‘c’
assert 4.5== f(1.5, 2.5)
```


  c. 按“Esc”键，输入:wq!，按“Enter”保存并退出编辑。
5. 执行以下命令再次测试。

```
python3 test2.py
```


  运行的示例将会报错，证明结论1.5+2.5=4.5是错误的。
