From ab67128544faffb40599ae45d7bb87836e35fce7 Mon Sep 17 00:00:00 2001 From: Vladimir Gorea Date: Sat, 13 Jan 2018 14:08:28 +0200 Subject: [PATCH] Implement Keras 2.0 release changes dim_ordering -> data_format border_mode -> padding float kernel dimension arguments become a single tuple argument, kernel size. E.g. a legacy call Conv2D(10, 3, 3) becomes Conv2D(10, (3, 3)) --- deeplearning2/vgg16.py | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/deeplearning2/vgg16.py b/deeplearning2/vgg16.py index e880cc6c7..a05d8588c 100644 --- a/deeplearning2/vgg16.py +++ b/deeplearning2/vgg16.py @@ -29,8 +29,8 @@ def VGG16(include_top=True, weights='imagenet', input_shape = _obtain_input_shape(input_shape, default_size=224, min_size=48, - dim_ordering=K.image_dim_ordering(), - include_top=include_top) + data_format=K.image_dim_ordering(), + require_flatten=include_top) if input_tensor is None: img_input = Input(shape=input_shape) @@ -40,31 +40,31 @@ def VGG16(include_top=True, weights='imagenet', else: img_input = input_tensor # Block 1 - x = Convolution2D(64, 3, 3, activation='relu', border_mode='same', name='block1_conv1')(img_input) - x = Convolution2D(64, 3, 3, activation='relu', border_mode='same', name='block1_conv2')(x) + x = Convolution2D(64, kernel_size=(3,3) activation='relu', padding='same', name='block1_conv1')(img_input) + x = Convolution2D(64, kernel_size=(3,3) activation='relu', padding='same', name='block1_conv2')(x) x = MaxPooling2D((2, 2), strides=(2, 2), name='block1_pool')(x) # Block 2 - x = Convolution2D(128, 3, 3, activation='relu', border_mode='same', name='block2_conv1')(x) - x = Convolution2D(128, 3, 3, activation='relu', border_mode='same', name='block2_conv2')(x) + x = Convolution2D(128, kernel_size=(3,3) activation='relu', padding='same', name='block2_conv1')(x) + x = Convolution2D(128, kernel_size=(3,3) activation='relu', padding='same', name='block2_conv2')(x) x = MaxPooling2D((2, 2), strides=(2, 2), name='block2_pool')(x) # Block 3 - x = Convolution2D(256, 3, 3, activation='relu', border_mode='same', name='block3_conv1')(x) - x = Convolution2D(256, 3, 3, activation='relu', border_mode='same', name='block3_conv2')(x) - x = Convolution2D(256, 3, 3, activation='relu', border_mode='same', name='block3_conv3')(x) + x = Convolution2D(256, kernel_size=(3,3) activation='relu', padding='same', name='block3_conv1')(x) + x = Convolution2D(256, kernel_size=(3,3) activation='relu', padding='same', name='block3_conv2')(x) + x = Convolution2D(256, kernel_size=(3,3) activation='relu', padding='same', name='block3_conv3')(x) x = MaxPooling2D((2, 2), strides=(2, 2), name='block3_pool')(x) # Block 4 - x = Convolution2D(512, 3, 3, activation='relu', border_mode='same', name='block4_conv1')(x) - x = Convolution2D(512, 3, 3, activation='relu', border_mode='same', name='block4_conv2')(x) - x = Convolution2D(512, 3, 3, activation='relu', border_mode='same', name='block4_conv3')(x) + x = Convolution2D(512, kernel_size=(3,3) activation='relu', padding='same', name='block4_conv1')(x) + x = Convolution2D(512, kernel_size=(3,3) activation='relu', padding='same', name='block4_conv2')(x) + x = Convolution2D(512, kernel_size=(3,3) activation='relu', padding='same', name='block4_conv3')(x) x = MaxPooling2D((2, 2), strides=(2, 2), name='block4_pool')(x) # Block 5 - x = Convolution2D(512, 3, 3, activation='relu', border_mode='same', name='block5_conv1')(x) - x = Convolution2D(512, 3, 3, activation='relu', border_mode='same', name='block5_conv2')(x) - x = Convolution2D(512, 3, 3, activation='relu', border_mode='same', name='block5_conv3')(x) + x = Convolution2D(512, kernel_size=(3,3) activation='relu', padding='same', name='block5_conv1')(x) + x = Convolution2D(512, kernel_size=(3,3) activation='relu', padding='same', name='block5_conv2')(x) + x = Convolution2D(512, kernel_size=(3,3) activation='relu', padding='same', name='block5_conv3')(x) x = MaxPooling2D((2, 2), strides=(2, 2), name='block5_pool')(x) if include_top: