Python keras_applications.imagenet_utils._obtain_input_shape() Examples
The following are 1
code examples of keras_applications.imagenet_utils._obtain_input_shape().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
keras_applications.imagenet_utils
, or try the search function
.
Example #1
Source File: hypertree_model.py From costar_plan with Apache License 2.0 | 4 votes |
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