Ubuntu 15.04 安装TensorFlow(源码编译) 及测试梵高作画

介绍Google的TensorFlow机器学习开源库,在UbuntuKylin上的安装和和源码编译。
原始官方文档参见:http://www.tensorflow.org.

本电脑配置如下:

3.19.0-15-generic #15-Ubuntu x86_64 GNU/Linux
NVIDIA Corporation GK110BGL [Tesla K40c]
NVIDIA Corporation GK110GL [Quadro K5200]
Python 2.7
Cuda toolkit = 7.5 
cuDNN = 7.5 v5
gcc = 4.9
g++ = 4.9  
Bazel = 0.4.4

TensorFlow学习资源推荐


tensorflow中文入门教程-含视频
tensorflow入门视频教程-含互动

tensorflow中文社区

TensorFlow 官方文档中文版

TensorFlow在图像识别中的应用


本文是在安装caffe之后,继续安装TensorFlow,下面有些CUDA和 CUDNN的安装可见 Caffe + Ubuntu 15.04 + CUDA 7.5 在服务器上安装配置及卸载重新安装(已测试可执行)

安装TensorFlow的Requirements

 Python 2.7 and Python 3.3+Cuda toolkit >= 7.0 cuDNN >= v3gcc > 4.8g++ > 4.8  Bazel > 0.4.2

一、安装依赖包



1. 安装Tensorflow python API


sudo apt-get install python-pip python-dev 
sudo apt-get install python-numpy swig python-dev 
sudo apt-get install Git

2. 安装 Bazel


TensorFlow Serving requires Bazel 0.4.2 or higher,Bazel的安装可见官网。

OpenJDK做为GPL许可(GPL-licensed)的Java平台的开源化实现,Sun正式发布它已经六年有余。从发布那一时刻起,Java社区的大众们就又开始努力学习,以适应这个新的开源代码基础(code-base)。 [1] 
OpenJDK在2013年发展迅速,被著名IT杂志SD Times评选为2013 SD Times 100,位于“极大影响力”分类第9位。http://www.infoq.com/cn/news/2015/03/google-open-source-bazel 
Google日前开源了他们内部使用的构建工具Bazel。 
Bazel是一个类似于Make的工具,是Google为其内部软件开发的特点量身定制的工具,如今Google使用它来构建内部大多数的软件。它的功能有诸多亮点: 
多语言支持:目前Bazel默认支持Java、Objective-CC++,但可以被扩展到其他任何变成语言。高级构建描述语言:项目是使用一种叫BUILD的语言来描述的,它是一种简洁的文本语言,它把一个项目视为一个集合,这个集合由一些互相关联的库、二进制文件和测试用例组成。相反,像Make这样的工具,需要去描述每个文件如何调用编译器。多平台支持:同一套工具和相同的BUILD文件可以用来为不同的体系结构构建软件,甚至是不同的平台。在Google,Bazel被同时用在数据中心系统中的服务器应用和手机端的移动应用上。可重复性:在BUILD文件中,每个库、测试用例和二进制文件都需要明确指定它们的依赖关系。当一个源码文件被修改时,Bazel凭这些依赖来判断哪些部分需要重新构建,以及哪些任务可以并行进行。这意味着所有构建都是增量的,并且相同构建总是产生一样的结果。可伸缩性:Bazel可以处理大型项目;在Google,一个服务器软件有十万行代码是很常见的,在什么都不改的前提下重新构建这样一个项目,大概只需要200毫秒。

JDK8的安装(必须的)

sudo apt-get install openjdk-8-jdk openjdk-8-source
sudo apt-get install pkg-config zip g++ zlib1g-dev unzip
sudo add-apt-repository ppa:webupd8team/java  #添加仓库
sudo apt-get update   #更新软件列表
sudo apt-get install oracle-java8-installer #正式安装jdk8
java -version      # 验证安装

2.1 安装 Bazel-方法1


echo “deb http://storage.googleapis.com/bazel-apt stable jdk1.8” | sudo tee /etc/apt/sources.list.d/bazel.list
curl https://storage.googleapis.com/bazel-apt/doc/apt-key.pub.gpg | sudo apt-key add -
sudo apt-get update 
sudo apt-get install bazel
sudo apt-get upgrade bazel
bazel version 

2.2 安装 Bazel-方法2


Bazel 下载链接

cd ~/Downloads
chmod +x bazel-0.4.5-installer-linux-x86_64.sh #对.sh文件授权
./bazel-0.4.5-installer-linux-x86_64.sh --user #运行.sh文件
bazel version

设置环境变量

export PATH="$PATH:$HOME/bin"

可能出现的问题


W: 无法下载 http://storage.googleapis.com/bazel-apt/dists/stable/InRelease Unable to find expected entry ‘jdk1.8/binary-i386/Packages’ in Release file (Wrong sources.list entry or malformed file) 
E: Some index files failed to download. They have been ignored, or old ones used instead. 
的错误

解决方法


sudo gedit /etc/apt/sources.list.d/bazel.list 
将deb http://storage.googleapis.com/bazel-apt stable jdk1.8修改为deb [arch=amd64] http://storage.googleapis.com/bazel-apt stable jdk1.8 

3. CUDA和 CUDNN的安装,在 Linux 上开启 GPU 支持


为了编译并运行能够使用 GPU 的 TensorFlow, 需要先安装 NVIDIA 提供的 Cuda Toolkit 7.5 和 CUDNN 7.5 V5


TensorFlow 的 GPU 特性只支持 NVidia Compute Capability >= 3.5 的显卡. 被支持的显卡 包括但不限于

NVidia TitanNVidia Titan XNVidia K20NVidia K40

可见 Caffe + Ubuntu 15.04 + CUDA 7.5 在服务器上安装配置及卸载重新安装(已测试可执行)


二、Ubuntu/Linux直接安装


# 仅使用 CPU 的版本
$ pip install https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-1.0.1-cp27-none-linux_x86_64.whl
# 开启 GPU 支持的版本 (安装该版本的前提是已经安装了 CUDA sdk)
$ pip install https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow-1.0.1-cp27-none-linux_x86_64.whl

三、源码编译



TensorFlow 源码安装官方教程



3.1 克隆 TensorFlow 仓库


git clone --recurse-submodules https://github.com/tensorflow/tensorflow   #拉取源代码

–recurse-submodules 参数是必须得, 用于获取 TesorFlow 依赖的 protobuf 库


3.2 配置 TensorFlow 的 Cuba 选项


cd tensorflow
./configure    # 配置tensorflow

执行configure的时候会问你问题

Please specify the location of python. [Default is /usr/bin/python]
Please specify optimization flags to use during compilation [Default is -march=native]
Do you wish to use jemalloc as the malloc implementation? [Y/N]
y
Do you wish to build TensorFlow with Google Cloud Platform support? [Y/N]
y
Do you wish to build TensorFlow with Hadoop File System support? [Y/N]
y
Do you wish to build TensorFlow with the XLA just-in-time compiler (experimental)? [Y/N]
y
Do you wish to build TensorFlow with OpenCL support? [Y/N]
n
Do you wish to build TensorFlow with CUDA support? [Y/N]
y

Do you wish to build TensorFlow with OpenCL support? [Y/N] 中选择 y,则需要安装 OpenCL drivers 和 ComputeCpp compiler,具体步骤可参考

Optional: Install OpenCL (Experimental, Linux only)

tensorflow-opencl

否则,会出现如下一直循环的情况。

这里写图片描述


3.3 编译


mkdir /tmp/tensorflow_pkg

3.3.1 仅 CPU 支持,无 GPU 支持


cd tensorflow
bazel build -c opt //tensorflow/tools/pip_package:build_pip_package

出现的问题


The 'build' command is only supported from within a workspace

解决方法


cd tensorflow

3.3.2 有 GPU 支持


cd tensorflow 
bazel build -c opt --config=cuda //tensorflow/tools/pip_package:build_pip_package 

3.3.3 生成 pip安装包


bazel-bin/tensorflow/tools/pip_package/build_pip_package /tmp/tensorflow_pkg

cd 到 /tmp/tensorflow_pkg目录下,找到编译好的whl文件

cd /tmp/tensorflow_pkg
sudo pip install --config=cuda tensorflow-1.0.1-cp27-none-linux_x86_64.whl

3.3.4 编译目标程序, 开启 GPU 支持


bazel build -c opt --config=cuda //tensorflow/cc:tutorials_example_trainerbazel-bin/tensorflow/cc/tutorials_example_trainer --use_gpu

四、设置TensorFlow环境


cd tensorflow 
bazel build -c opt //tensorflow/tools/pip_package:build_pip_package# To build with GPU support:
bazel build -c opt --config=cuda //tensorflow/tools/pip_package:build_pip_package
mkdir _python_build
cd _python_build
ln -s ../bazel-bin/tensorflow/tools/pip_package/build_pip_package.runfiles/org_tensorflow/* .
ln -s ../tensorflow/tools/pip_package/* .
sudo python setup.py develop

五、测试TensorFlow


import tensorflow as tf
hello = tf.constant('Hello, TensorFlow!')
sess = tf.Session()
print(sess.run(hello))
Hello, TensorFlow!

a = tf.constant(10)
b = tf.constant(32)
print(sess.run(a+b))
42


用tensorflow实现梵高作画


1. neural-style下载在这个[github网站下载相应代码]


2. 下载vgg19


3. 将imagenet-vgg-verydeep-19.mat复制到neural-style的文件夹根目录下

cp -r imagenet-vgg-verydeep-19.mat /home/bids/neural-style-master/

4. 执行梵高作画

python neural_style.py –content ./example/xxx.jpg (此括号内不要复制:xxx代表你想要使用的图片名称) –styles ./example/ 1-style.jpg(此括号内不要复制:1-style.jpg是梵高星空图片在文件夹内名称) –output ./example/yyy.jpg (yyy代表你想要生成的图片名称)

cd neural-style-master
python neural_style.py –content  ./example/1-content.jpg  --styles ./example/1-style.jpg --output ./example/1-output.jpg

六、出现的问题



gcc 版本 -fno-canonical-system-headers


当执行

./configure

出现如下问题

INFO: Found 1 target...
Slow read: a 51765952-byte read from /home/bids/.cache/bazel/_bazel_bids/5df0e0fb624204ab1c5ce0472e695b94/external/local_config_cuda/cuda/lib/libcurand.so.7.5 took 9675ms.
INFO: From Compiling external/llvm/lib/Support/Host.cpp:
external/llvm/lib/Support/Host.cpp: In function 'llvm::StringRef llvm::sys::getHostCPUName()':
external/llvm/lib/Support/Host.cpp:898:5: warning: 'Type' may be used uninitialized in this function [-Wuninitialized]
external/llvm/lib/Support/Host.cpp:964:7: warning: 'Subtype' may be used uninitialized in this function [-Wmaybe-uninitialized]
ERROR: /home/bids/.cache/bazel/_bazel_bids/5df0e0fb624204ab1c5ce0472e695b94/external/llvm/BUILD:1667:1: C++ compilation of rule '@llvm//:support' failed: gcc failed: error executing command /usr/bin/gcc -U_FORTIFY_SOURCE -fstack-protector -Wall -B/usr/bin -B/usr/bin -Wunused-but-set-parameter -Wno-free-nonheap-object -fno-omit-frame-pointer -g0 -O2 '-D_FORTIFY_SOURCE=1' -DNDEBUG ... (remaining 43 argument(s) skipped): com.google.devtools.build.lib.shell.BadExitStatusException: Process exited with status 1.
In file included from external/llvm/lib/Support/DynamicLibrary.cpp:16:0:
external/llvm/include/llvm/ADT/DenseSet.h:226:16: error: 'using llvm::DenseSet<ValueT, ValueInfoT>::BaseT::BaseT' conflicts with a previous declaration
external/llvm/include/llvm/ADT/DenseSet.h:223:39: note: previous declaration 'using BaseT = class llvm::detail::DenseSetImpl<ValueT, llvm::DenseMap<ValueT, llvm::detail::DenseSetEmpty, ValueInfoT, llvm::detail::DenseSetPair<ValueT> >, ValueInfoT>'
external/llvm/include/llvm/ADT/DenseSet.h:244:16: error: 'using llvm::SmallDenseSet<ValueT, InlineBuckets, ValueInfoT>::BaseT::BaseT' conflicts with a previous declaration
external/llvm/include/llvm/ADT/DenseSet.h:241:18: note: previous declaration 'using BaseT = class llvm::detail::DenseSetImpl<ValueT, llvm::SmallDenseMap<ValueT, llvm::detail::DenseSetEmpty, InlineBuckets, ValueInfoT, llvm::detail::DenseSetPair<ValueT> >, ValueInfoT>'
Target //tensorflow/tools/pip_package:build_pip_package failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 54.671s, Critical Path: 28.01s
bids@bids-HP-Z840-Workstation:~/tensorflow$ bazel build -c opt --config=cuda //tensorflow/tools/pip_package:build_pip_package
WARNING: /home/bids/tensorflow/tensorflow/contrib/learn/BUILD:15:1: in py_library rule //tensorflow/contrib/learn:learn: target '//tensorflow/contrib/learn:learn' depends on deprecated target '//tensorflow/contrib/session_bundle:exporter': Use SavedModel Builder instead.
WARNING: /home/bids/tensorflow/tensorflow/contrib/learn/BUILD:15:1: in py_library rule //tensorflow/contrib/learn:learn: target '//tensorflow/contrib/learn:learn' depends on deprecated target '//tensorflow/contrib/session_bundle:gc': Use SavedModel instead.
INFO: Found 1 target...
ERROR: /home/bids/.cache/bazel/_bazel_bids/5df0e0fb624204ab1c5ce0472e695b94/external/zlib_archive/BUILD.bazel:5:1: C++ compilation of rule '@zlib_archive//:zlib' failed: crosstool_wrapper_driver_is_not_gcc failed: error executing command external/local_config_cuda/crosstool/clang/bin/crosstool_wrapper_driver_is_not_gcc -U_FORTIFY_SOURCE '-D_FORTIFY_SOURCE=1' -fstack-protector -fPIE -Wall -Wunused-but-set-parameter ... (remaining 37 argument(s) skipped): com.google.devtools.build.lib.shell.BadExitStatusException: Process exited with status 1.
gcc: error: unrecognized command line option '-fno-canonical-system-headers'
Target //tensorflow/tools/pip_package:build_pip_package failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 4.726s, Critical Path: 1.88s

解决方法:


这是因为gcc 版本的问题。因之前安装caffe 所需的gcc版本为4.7,故升级到4.9版本即可。可参考

Porting to GCC 4.7
Caffe + Ubuntu 15.04 + CUDA 7.5 在服务器上安装配置及卸载重新安装(已测试可执行)

cd /usr/bin
sudo rm gcc
sudo ln -s gcc-4.9 gcc
sudo rm g++
sudo ln -s g++-4.9 g++

问题 Oracle JDK 8 is not installed


当执行如下

sudo apt-get install openjdk-8-jdk openjdk-8-source

出现如下错误

download failed
Oracle JDK 8 is NOT installed.
dpkg: error processing package oracle-java8-installer (--configure):subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:oracle-java8-installer
E: Sub-process /usr/bin/dpkg returned an error code (1)

解决方法: 这是因为oracle-java8-installer 不能下载或者下载不完整导致的。


手动下载,见链接。

cp -r jdk-8u121-linux-x64.tar.gz /var/cache/oracle-jdk8-installer/
sudo apt-get install oracle-jdk8-installer

问题 TensorFlow ImportError: cannot import name pywrap_tensorflow


当执行如下

cd tensorflowimport tensorflow as tf

出现如下错误

Traceback (most recent call last):File "<stdin>", line 1, in <module>File "tensorflow/__init__.py", line 23, in <module>from tensorflow.Python import *File "tensorflow/python/__init__.py", line 48, in <module>from tensorflow.python import pywrap_tensorflowImportError: cannot import name pywrap_tensorflow

解决方法: 这是因为python误以为tensorflow目录中的tensorflow就是要导入的模块


不要在tensorflow中运行python或者ipython


更改keras的backend 设置 tensorflow,theano

sudo gedit ~/.keras/keras.json

Theano为后端

{"image_dim_ordering": "th", "epsilon": 1e-07, "floatx": "float32", "backend": "theano"
}

Tensorflow为后端

{"image_dim_ordering": "tf", "epsilon": 1e-07, "floatx": "float32", "backend": "tensorflow"
}

参考文献:



TensorFlow源码编译-基于Ubuntu 15.04

TensorFlow 研究实践 一

Ubuntu安装Bazel

官网教程 Installing Bazel

搭建Tensorflow虚拟机学习环境

TensorFlow的安装

TensorFlow 从入门到精通(一):安装和使用

ubuntu16.04下安装TensorFlow(GPU加速)—-详细图文教程

Ubuntu: Oracle JDK 8 is NOT installed

教你从头到尾利用DL学梵高作画:GTX 1070 cuda 8.0 tensorflow gpu版

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/246861.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

Ubuntu 15.04 安装 boost-python

1. 安装依赖库 sudo apt-get install python-dev sudo apt-get install mpi-default-dev #安装mpi库 sudo apt-get install libicu-dev #支持正则表达式的&#xff35;&#xff2e;&#xff29;&#xff23;&#xff2f;&#xff24;&#xff25;字符集 sudo apt-get install …

python 常见问题汇总(待续)

1. No module named skimage pip install scikit-image --upgrade 2. No module named dicom sudo pip install pydicom 3. python name ‘os’ is not defined import os This will import the python’s module os, which apparently is used later in the code of your m…

如何将 ipynb 发布到 blog 中(html, markdown格式)

相关文章链接 如何向IPython Notebook中导入.py文件 如何将 ipynb 发布到 blog 中(html, markdown格式) Introducing IPython Notebook Beginner’s IPython Notebook Tutorial Example notebook showing how to do statistics in IPython Notebook next generation slide…

HP Z840 工作站配sSAS Raid 安装 Ubuntu 16.04 系统

惠普Z840工作站配SAS RAID安装win7系统加载驱动 安装ubuntu的最低版本版本要求是01.25&#xff0c;请更新到官方最新的02.31测试 1. BIOS系统更新 1. 准备好一个空的U盘&#xff0c;格式化成FAT32&#xff0c;在U盘上建立\Hewlett-Packard\BIOS\New 2. 下载链接http://ftp.hp…

Ubuntu SSH Algorithm negotiation failed

问题 解决方法 chmod 777 /etc/ssh/sshd_configgedit /etc/ssh/sshd_config添加如下 Ciphers aes128-cbc,aes192-cbc,aes256-cbc,aes128-ctr,aes192-ctr,aes256-ctr,3des-cbc,arcfour128,arcfour256,arcfour,blowfish-cbc,cast128-cbcMACs hmac-md5,hmac-sha1,umac-64openssh.…

不同matlab版本所支持的gcc g+版本

问题 关于 GCC 和 G 版本问题 Matlab 2014a gcc/g 4.7.x, Matlab 2016a gcc/g 4.9.x Matlab 2017a gcc/g 4.9.x Ubuntu 15.04 gcc/g 4.9.x, Ubuntu 16.04 gcc/g 5.4.x 原则上Matlab需要和Ubuntu版本一致&#xff0c;由于CUDA 8只支持16.04,而且需要GCC 5.4.x 进行编译&#…

Linux系统中添加硬盘,并挂载到已有的目录,比如/home/user

备份用户下数据 cd home ls newuser tar cvf newuser.tar newuser  &#xff03;创建一个tar归档 rm -rf newuser mkdir newuser备注&#xff1a;newuser为home下的用户。 分区和挂载 #查看硬盘分区 fdisk -l#分区 fdisk /dev/sdbCommand (m for help):m#新建一个分区 Comman…

高性能Numpy/Scipy加速:使用Intel MKL和Intel Compilers或OpenBLAS(待续)

Numpy/Scipy加速:使用Intel MKL和Intel Compilers 1.获取Intel Parallel Studio XE Intel免费软件工具提供免费的软件包&#xff0c;其中包括完整的Intel编译器和计算库及其激活码&#xff0c;软件和激活码一一对应。注意需要使用教育邮箱注册&#xff0c;否则不予通过。 2.安装…

Linux 安装卸载软件及管理软件仓库

软件仓库 Linux的软件包都存放在一个地方&#xff0c;叫做软件仓库&#xff0c;repository。 因为Linux是在Windows之后诞生的&#xff08;1991年前后&#xff09;&#xff0c;所以为了避免Windows的这个“弊端”&#xff0c;Linux选择创建一个集中存放软件的地方。 当然了&a…

Linux 终端配置

一般Linux中的配置文件大多以点开头&#xff0c;而且多以rc结尾。比如vim的配置文件 .vimrc&#xff0c;bash shell的配置文件.bashrc&#xff0c;等等。 像这样的配置文件&#xff0c;如果用ls -l命令是列不出来的&#xff0c;需要用ls -a来列出。 “rc”&#xff0c;它是“…

Caffe2 Compilation Error gflags.cc' is being linked both statically and dynamically into this execut

问题描述 python -c from caffe2.python import core 2>/dev/null && echo "Success" || echo "Failure" 出现这个问题 ERROR: something wrong with flag flagfile in file /home/bids/softwares/gflags-2.2.0/src/gflags.cc. One possibil…

值得关注的医疗 AI 公司(待续)

医疗成像 Clearview Diagnostics 是一家开发辅助医生诊断疾病的工具的 AI 软件公司。该公司最初的重点是乳腺癌。 Butterfly Network 是一家医疗成像技术公司&#xff0c;该公司创建了一个集成了深度学习技术的便携式医疗成像设备&#xff0c;帮助缺乏医疗机构或医生不够专业的…

caffe2 介绍

Caffe2的特性 Caffe2框架可以通过一台机器上的多个GPU或具有一个及多个GPU的多台机器来进行分布式训练。 也可以在iOS系统、Android系统和树莓派&#xff08;Raspberry Pi&#xff09;上训练和部署模型。只需要运行几行代码即可调用Caffe2中预先训练好的Model Zoo模型。Caffe2…

如何向IPython Notebook中导入.py文件

相关文章链接 如何向IPython Notebook中导入.py文件 如何将 ipynb 发布到 blog 中(html, markdown格式) Introducing IPython Notebook Beginner’s IPython Notebook Tutorial Example notebook showing how to do statistics in IPython Notebook next generation sli…

Python 中的numpy 库

待总结 用scikit-learn和pandas学习线性回归 用scikit-learn和pandas学习Ridge回归 待整理的 Numpy & Pandas numpy——主要对其 N 维数组对象有用 http://www.numpy.org/ Pandas数据转为 numpy数据 df_numpyMatrix df.as_matrix() df_numpyMatrixdf.values a([3.23…

Python 中的Pandas库

待总结 用scikit-learn和pandas学习线性回归 用scikit-learn和pandas学习Ridge回归 基于python的数据分析库Pandas pandas——Python 数据分析库&#xff0c;包括数据框架&#xff08;dataframes&#xff09;等结构 http://pandas.pydata.org/ 10 Minutes to Pandas&#…

weka和matlab完成完整分类实验

本文 本文简单介绍数据集介绍、weka的使用、weka与LIBSVM、matlab与LIBSVM以及分类的若干细节问题。 1. 数据集介绍 打开网址UCI数据集&#xff0c;如下图。 从右下角可以看到Iris这个数据集&#xff0c;这是使用最多的数据集&#xff0c;目前下载量超过了82万。 打开之后跳…

Python 中的绘图matplotlib mayavi库

python matplotlib 图像可视化 python-data-visualization-course Interactive Web Plotting for Python Interactive Web Plotting for Python-github 待整理的 Matplotlib Introduction to Matplotlib and basic line matplotlib——一个 2D 绘图库&#xff0c;可产生…

python -pass的用法

空语句 熟悉C/C的经常会这样写判断语句&#xff1a; if&#xff08;ture&#xff09;expression; else;//do nothing 那在Python里面怎么去表达空语句呢&#xff0c;这时候就用到了pass。 number input(请输入一个数) if number 5:print(your numbers is 5) else:pass 实际…

python -lambda表达式的用法

匿名函数 lambda的意义&#xff1a; 利用lambda我们可以速写函数&#xff0c;不用去定义函数就可以直接使用 y lambda x,z:59*x8*z print(y(2,4)) 从例子中可以看到&#xff0c;lambda的语法结构是&#xff1a; lambda input : output expression lambda的用法比较简单&…