首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往
您找到你想要的搜索结果了吗?
是的
没有找到

python基础6

*******************             *  异常处理与调式         *             ******************* ***常见错误:*** 1) 名字没有定义,NameError In [1]: print a --------------------------------------------------------------------------- NameError                                 Traceback (most recent call last) <ipython-input-1-9d7b17ad5387> in <module>() ----> 1 print a NameError: name 'a' is not defined 2) 分母为零,ZeroDivisionError In [2]: 10/0 --------------------------------------------------------------------------- ZeroDivisionError                         Traceback (most recent call last) <ipython-input-2-242277fd9e32> in <module>() ----> 1 10/0 ZeroDivisionError: integer division or modulo by zero 3) 文件不存在,IOError In [3]: open("westos") --------------------------------------------------------------------------- IOError                                   Traceback (most recent call last) <ipython-input-3-2778d2991600> in <module>() ----> 1 open("westos") IOError: [Errno 2] No such file or directory: 'westos' 4) 语法错误,SyntaxError In [4]: for i in [1,2,3]   File "<ipython-input-4-ae71676907af>", line 1     for i in [1,2,3]                     ^ SyntaxError: invalid syntax 5) 索引超出范围,IndexError In [5]: a = [1,2,3] In [6]: a[3] --------------------------------------------------------------------------- IndexError                                Traceback (most recent call last) <ipython-input-6-94e7916e7615> in <module>() ----> 1 a[3] IndexError: list index out of range In [7]: t =(1,2,3) In [8]: t[3] --------------------------------------------------------------------------- IndexError                                Traceback (most recent call last) <ipython-input-8-7d5cf04057c5> in <module>() ----> 1 t[3] IndexError: tuple index out of range In [9]: t[1:9]            ###切片的时候,若超出范围,则默认为全部,不报错 Out[9]: (2, 3) ####python异常处理机制:try......except......finally###### 例: #!/usr/bin/env python #coding:utf-8 try:                ###将可能发生错误的部分放在try下###     print "staring......"     li = [1,2,3]     print a     pri

02

TensorRT安装及使用教程「建议收藏」

一般的深度学习项目,训练时为了加快速度,会使用多 GPU 分布式训练。但在部署推理时,为了降低成本,往往使用单个 GPU 机器甚至嵌入式平台(比如 NVIDIA Jetson)进行部署,部署端也要有与训练时相同的深度学习环境,如 caffe,TensorFlow 等。由于训练的网络模型可能会很大(比如,inception,resnet 等),参数很多,而且部署端的机器性能存在差异,就会导致推理速度慢,延迟高。这对于那些高实时性的应用场合是致命的,比如自动驾驶要求实时目标检测,目标追踪等。所以为了提高部署推理的速度,出现了很多轻量级神经网络,比如 squeezenet,mobilenet,shufflenet 等。基本做法都是基于现有的经典模型提出一种新的模型结构,然后用这些改造过的模型重新训练,再重新部署。

03
领券