本文整理汇总了Python中keras_applications.imagenet_utils._obtain_input_shape方法的典型用法代码示例。如果您正苦于以下问题:Python imagenet_utils._obtain_input_shape方法的具体用法?Python imagenet_utils._obtain_input_shape怎么用?Python imagenet_utils._obtain_input_shape使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类keras_applications.imagenet_utils
的用法示例。
在下文中一共展示了imagenet_utils._obtain_input_shape方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: classifier_block
# 需要导入模块: from keras_applications import imagenet_utils [as 别名]
# 或者: from keras_applications.imagenet_utils import _obtain_input_shape [as 别名]
def classifier_block(input_tensor, include_top=True, top='classification',
classes=1, activation='sigmoid',
input_shape=None, final_pooling=None, name='', verbose=1):
""" Performs the final Activation for the classification of a given problem.
# Arguments
include_top: Whether to include the fully-connected
layer at the top of the network. Also maps to require_flatten
option in `keras.applications.imagenet_utils._obtain_input_shape()`.
"""
x = input_tensor
if include_top and top == 'classification':
if verbose:
print(" classification of x: " + str(x))
x = Dense(units=classes, activation=activation,
kernel_initializer="he_normal", name=name + 'fc' + str(classes))(x)
elif include_top and top == 'segmentation':
if verbose > 0:
print(" segmentation of x: " + str(x))
x = Conv2D(classes, (1, 1), activation='linear', padding='same')(x)
if K.image_data_format() == 'channels_first':
channel, row, col = input_shape
else:
row, col, channel = input_shape
x = Reshape((row * col, classes))(x)
x = Activation(activation)(x)
x = Reshape((row, col, classes))(x)
elif include_top and top == 'quaternion':
x = Dense(units=classes, activation='linear',
kernel_initializer="he_normal", name=name + 'fc' + str(classes))(x)
# normalize the output so we have a unit quaternion
x = Lambda(lambda x: K.l2_normalize(x, axis=1))(x)
elif final_pooling == 'avg':
if verbose:
print(" GlobalAveragePooling2D")
x = GlobalAveragePooling2D()(x)
elif final_pooling == 'max':
if verbose:
print(" GlobalMaxPooling2D")
x = GlobalMaxPooling2D()(x)
else:
raise ValueError('hypertree_model.py::classifier_block() unsupported top: ' + str(top))
return x