reload(alex_net_utils) np.random.seed(7) # Set the random seed for reproducibility if __name__ == "__main__": plt.ion() # 1. Build the model # --------------------------------------------------------------------- K.set_image_dim_ordering('th') print("Building Contour Integration Model...") # Gaussian Multiplicative Model contour_integration_model = cont_int_models.build_contour_integration_model( "masked_multiplicative", "trained_models/AlexNet/alexnet_weights.h5", weights_type='enhance', n=25, ) # 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) # 2. Extract the neural data we would like to match # --------------------------------------------------------------------- with open('.//neuro_data//Li2006.pickle', 'rb') as handle: data = pickle.load(handle)
if __name__ == "__main__": plt.ion() K.clear_session() K.set_image_dim_ordering('th') # -------------------------- tgt_filter_idx = 10 # 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()
return f if __name__ == "__main__": plt.ion() K.clear_session() # 1. Load/Make the model # ---------------------- K.set_image_dim_ordering('th') print("Building Contour Integration Model...") # Gaussian Multiplicative Model contour_integration_model = cont_int_models.build_contour_integration_model( "gaussian_multiplicative", "trained_models/AlexNet/alexnet_weights.h5", weights_type='enhance_and_suppress', n=25, sigma=6.0) # 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) # -------------------------------------------------------------------------------------------- # Vertical Contours # -------------------------------------------------------------------------------------------- tgt_filter_index = 10