Python常用函数

1. 序列整数(range函数)

2. 断言assert

assert 表达式

如果表达式为Ture,则对程序没有影响,继续运行

如果表达式为False,则会抛出AssertionError,程序停止运行

例子:assert image_shape[1] != filter_shape[1]

这里的image_shape为(500,1,28,28)

filter_shape为(20,1,5,5)

可见image_shape[1] =1   ==    filter_shape[1] =1

所以,表达式assert image_shape[1] != filter_shape[1]为False,程序出错,抛出AssertionError

原文地址:https://www.cnblogs.com/lutingting/p/5156476.html