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