Instantiates the VGG19 architecture. Optionally loads weights pre-trained on ImageNet. Note that when using TensorFlow, for best performance you should set `image_data_format="channels_last"` in your Keras config at ~/.keras/keras.json. The model and the weights are compati
(include_top=True, weights='imagenet',
input_tensor=None, input_shape=None,
pooling=None,
classes=1000)
| 32 | |
| 33 | |
| 34 | def VGG19(include_top=True, weights='imagenet', |
| 35 | input_tensor=None, input_shape=None, |
| 36 | pooling=None, |
| 37 | classes=1000): |
| 38 | """Instantiates the VGG19 architecture. |
| 39 | |
| 40 | Optionally loads weights pre-trained |
| 41 | on ImageNet. Note that when using TensorFlow, |
| 42 | for best performance you should set |
| 43 | `image_data_format="channels_last"` in your Keras config |
| 44 | at ~/.keras/keras.json. |
| 45 | |
| 46 | The model and the weights are compatible with both |
| 47 | TensorFlow and Theano. The data format |
| 48 | convention used by the model is the one |
| 49 | specified in your Keras config file. |
| 50 | |
| 51 | # Arguments |
| 52 | include_top: whether to include the 3 fully-connected |
| 53 | layers at the top of the network. |
| 54 | weights: one of `None` (random initialization) |
| 55 | or "imagenet" (pre-training on ImageNet). |
| 56 | input_tensor: optional Keras tensor (i.e. output of `layers.Input()`) |
| 57 | to use as image input for the model. |
| 58 | input_shape: optional shape tuple, only to be specified |
| 59 | if `include_top` is False (otherwise the input shape |
| 60 | has to be `(224, 224, 3)` (with `channels_last` data format) |
| 61 | or `(3, 224, 244)` (with `channels_first` data format). |
| 62 | It should have exactly 3 inputs channels, |
| 63 | and width and height should be no smaller than 48. |
| 64 | E.g. `(200, 200, 3)` would be one valid value. |
| 65 | pooling: Optional pooling mode for feature extraction |
| 66 | when `include_top` is `False`. |
| 67 | - `None` means that the output of the model will be |
| 68 | the 4D tensor output of the |
| 69 | last convolutional layer. |
| 70 | - `avg` means that global average pooling |
| 71 | will be applied to the output of the |
| 72 | last convolutional layer, and thus |
| 73 | the output of the model will be a 2D tensor. |
| 74 | - `max` means that global max pooling will |
| 75 | be applied. |
| 76 | classes: optional number of classes to classify images |
| 77 | into, only to be specified if `include_top` is True, and |
| 78 | if no `weights` argument is specified. |
| 79 | |
| 80 | # Returns |
| 81 | A Keras model instance. |
| 82 | |
| 83 | # Raises |
| 84 | ValueError: in case of invalid argument for `weights`, |
| 85 | or invalid input shape. |
| 86 | """ |
| 87 | if weights not in {'imagenet', None}: |
| 88 | raise ValueError('The `weights` argument should be either ' |
| 89 | '`None` (random initialization) or `imagenet` ' |
| 90 | '(pre-training on ImageNet).') |
| 91 |