本文整理匯總了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