当前位置: 首页>>代码示例>>Python>>正文


Python imagenet_utils._obtain_input_shape方法代码示例

本文整理汇总了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 
开发者ID:jhu-lcsr,项目名称:costar_plan,代码行数:50,代码来源:hypertree_model.py


注:本文中的keras_applications.imagenet_utils._obtain_input_shape方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。