Beispiel #1
0
    # Build Contour Integration Model
    # -------------------------------
    print("Building Contour Integration Model...")

    # Multiplicative Model
    contour_integration_model = cont_int_models.build_contour_integration_model(
        "multiplicative",
        "trained_models/AlexNet/alexnet_weights.h5",
        n=25,
        activation='relu')
    # contour_integration_model.summary()

    # Define callback functions to get activations of L1 convolutional layer &
    # L2 contour integration layer
    l1_activations_cb = alex_net_utils.get_activation_cb(
        contour_integration_model, 1)
    l2_activations_cb = alex_net_utils.get_activation_cb(
        contour_integration_model, 2)

    # Store the start weights & bias for comparison later
    start_weights, start_bias = contour_integration_model.layers[
        2].get_weights()

    # Build the Contour Image Generator
    # ---------------------------------
    print("Building Train Image Generator ...")
    feature_extract_kernels = K.eval(
        contour_integration_model.layers[1].weights[0])
    feature_extract_kernel = feature_extract_kernels[:, :, :, tgt_filter_idx]

    fragment = np.zeros((11, 11, 3))
Beispiel #2
0
    #     activation='relu'
    # )

    # Multiplicative Model
    contour_integration_model = cont_int_models.build_contour_integration_model(
        "multiplicative",
        "trained_models/AlexNet/alexnet_weights.h5",
        n=25,
        activation='relu')
    # contour_integration_model.summary()

    feat_extract_kernels = K.eval(
        contour_integration_model.layers[1].weights[0])

    # callbacks to get activations of first feature extracting & contour integration layers
    feat_extract_activations_cb = alex_net_utils.get_activation_cb(
        contour_integration_model, 1)
    cont_int_activations_cb = alex_net_utils.get_activation_cb(
        contour_integration_model, 2)

    # Store the start weights & bias for comparison later
    start_weights, start_bias = contour_integration_model.layers[
        2].get_weights()

    # Feature extracting kernel to target
    # ------------------------------------------------------------------------
    tgt_feat_extract_kernel_idx = 54

    tgt_filter_idx = feat_extract_kernels[:, :, :, tgt_feat_extract_kernel_idx]
    tgt_filter_len = tgt_filter_idx.shape[0]

    tgt_neuron_loc = (27, 27)