def conv_2d(filters, kernel_shape, strides, padding):
"""
Defines the right convolutional layer according to the
version of Keras that is installed.
:param filters: (required integer) the dimensionality of the output
space (i.e. the number output of filters in the
convolution)
:param kernel_shape: (required tuple or list of 2 integers) specifies
the strides of the convolution along the width and
height.
:param padding: (required string) can be either 'valid' (no padding around
input or feature map) or 'same' (pad to ensure that the
output feature map size is identical to the layer input)
:return: the Keras layer
"""
if LooseVersion(keras.__version__) >= LooseVersion('2.0.0'):
return Conv2D(filters=filters, kernel_size=kernel_shape,
strides=strides, padding=padding)
else:
return Convolution2D(filters, kernel_shape[0], kernel_shape[1],
subsample=strides, border_mode=padding)
# the cnn_model used
jsmacifar.py 文件源码
python
阅读 24
收藏 0
点赞 0
评论 0
评论列表
文章目录