94b86c420f2c8fe484a177a77dbfec76a018bd0a,keras/applications/resnet50.py,,ResNet50,#Any#Any#Any#Any#Any#Any#,124

Before Change


        ValueError: in case of invalid argument for `weights`,
            or invalid input shape.
    
    if weights not in {"imagenet", None}:
        raise ValueError("The `weights` argument should be either "
                         "`None` (random initialization) or `imagenet` "
                         "(pre-training on ImageNet).")

After Change


        ValueError: in case of invalid argument for `weights`,
            or invalid input shape.
    
    if not (weights in {"imagenet", None} or os.path.exists(weights)):
        raise ValueError("The `weights` argument should be either "
                         "`None` (random initialization), `imagenet` "
                         "(pre-training on ImageNet), "
                         "or the path to the weights file to be loaded.")

    if weights == "imagenet" and include_top and classes != 1000:
        raise ValueError("If using `weights` as imagenet with `include_top`"
                         " as true, `classes` should be 1000")

    // Determine proper input shape
    input_shape = _obtain_input_shape(input_shape,
                                      default_size=224,
                                      min_size=197,
                                      data_format=K.image_data_format(),
                                      require_flatten=include_top,
                                      weights=weights)

    if input_tensor is None:
        img_input = Input(shape=input_shape)
    else:
        if not K.is_keras_tensor(input_tensor):
            img_input = Input(tensor=input_tensor, shape=input_shape)
        else:
            img_input = input_tensor
    if K.image_data_format() == "channels_last":
        bn_axis = 3
    else:
        bn_axis = 1

    x = Conv2D(
        64, (7, 7), strides=(2, 2), padding="same", name="conv1")(img_input)
    x = BatchNormalization(axis=bn_axis, name="bn_conv1")(x)
    x = Activation("relu")(x)
    x = MaxPooling2D((3, 3), strides=(2, 2))(x)

    x = conv_block(x, 3, [64, 64, 256], stage=2, block="a", strides=(1, 1))
    x = identity_block(x, 3, [64, 64, 256], stage=2, block="b")
    x = identity_block(x, 3, [64, 64, 256], stage=2, block="c")

    x = conv_block(x, 3, [128, 128, 512], stage=3, block="a")
    x = identity_block(x, 3, [128, 128, 512], stage=3, block="b")
    x = identity_block(x, 3, [128, 128, 512], stage=3, block="c")
    x = identity_block(x, 3, [128, 128, 512], stage=3, block="d")

    x = conv_block(x, 3, [256, 256, 1024], stage=4, block="a")
    x = identity_block(x, 3, [256, 256, 1024], stage=4, block="b")
    x = identity_block(x, 3, [256, 256, 1024], stage=4, block="c")
    x = identity_block(x, 3, [256, 256, 1024], stage=4, block="d")
    x = identity_block(x, 3, [256, 256, 1024], stage=4, block="e")
    x = identity_block(x, 3, [256, 256, 1024], stage=4, block="f")

    x = conv_block(x, 3, [512, 512, 2048], stage=5, block="a")
    x = identity_block(x, 3, [512, 512, 2048], stage=5, block="b")
    x = identity_block(x, 3, [512, 512, 2048], stage=5, block="c")

    x = AveragePooling2D((7, 7), name="avg_pool")(x)

    if include_top:
        x = Flatten()(x)
        x = Dense(classes, activation="softmax", name="fc1000")(x)
    else:
        if pooling == "avg":
            x = GlobalAveragePooling2D()(x)
        elif pooling == "max":
            x = GlobalMaxPooling2D()(x)

    // Ensure that the model takes into account
    // any potential predecessors of `input_tensor`.
    if input_tensor is not None:
        inputs = get_source_inputs(input_tensor)
    else:
        inputs = img_input
    // Create model.
    model = Model(inputs, x, name="resnet50")

    // load weights
    if weights == "imagenet":
        if include_top:
            weights_path = get_file("resnet50_weights_tf_dim_ordering_tf_kernels.h5",
                                    WEIGHTS_PATH,
                                    cache_subdir="models",
                                    md5_hash="a7b3fe01876f51b976af0dea6bc144eb")
        else:
            weights_path = get_file("resnet50_weights_tf_dim_ordering_tf_kernels_notop.h5",
                                    WEIGHTS_PATH_NO_TOP,
                                    cache_subdir="models",
                                    md5_hash="a268eb855778b3df3c7506639542a6af")
        model.load_weights(weights_path)
        if K.backend() == "theano":
            layer_utils.convert_all_kernels_in_model(model)
            if include_top:
                maxpool = model.get_layer(name="avg_pool")
                shape = maxpool.output_shape[1:]
                dense = model.get_layer(name="fc1000")
                layer_utils.convert_dense_weights_data_format(dense, shape, "channels_first")

        if K.image_data_format() == "channels_first" and K.backend() == "tensorflow":
            warnings.warn("You are using the TensorFlow backend, yet you "
                          "are using the Theano "
                          "image data format convention "
                          "(`image_data_format="channels_first"`). "
                          "For best performance, set "
                          "`image_data_format="channels_last"` in "
                          "your Keras config "
                          "at ~/.keras/keras.json.")
    elif weights is not None:
        model.load_weights(weights)

    return model
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 6

Non-data size: 12

Instances


Project Name: keras-team/keras
Commit Name: 94b86c420f2c8fe484a177a77dbfec76a018bd0a
Time: 2017-11-30
Author: dansbecker@gmail.com
File Name: keras/applications/resnet50.py
Class Name:
Method Name: ResNet50


Project Name: keras-team/keras
Commit Name: 94b86c420f2c8fe484a177a77dbfec76a018bd0a
Time: 2017-11-30
Author: dansbecker@gmail.com
File Name: keras/applications/mobilenet.py
Class Name:
Method Name: MobileNet


Project Name: keras-team/keras
Commit Name: 94b86c420f2c8fe484a177a77dbfec76a018bd0a
Time: 2017-11-30
Author: dansbecker@gmail.com
File Name: keras/applications/vgg16.py
Class Name:
Method Name: VGG16


Project Name: keras-team/keras
Commit Name: 94b86c420f2c8fe484a177a77dbfec76a018bd0a
Time: 2017-11-30
Author: dansbecker@gmail.com
File Name: keras/applications/xception.py
Class Name:
Method Name: Xception


Project Name: keras-team/keras
Commit Name: 94b86c420f2c8fe484a177a77dbfec76a018bd0a
Time: 2017-11-30
Author: dansbecker@gmail.com
File Name: keras/applications/inception_resnet_v2.py
Class Name:
Method Name: InceptionResNetV2


Project Name: keras-team/keras
Commit Name: 94b86c420f2c8fe484a177a77dbfec76a018bd0a
Time: 2017-11-30
Author: dansbecker@gmail.com
File Name: keras/applications/vgg19.py
Class Name:
Method Name: VGG19